Re: [PATCH spice-gtk 2/3] fixup! Gstreamer: Control GstVideoOverlay from the widget

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 12/17/18 11:51 AM, Frediano Ziglio wrote:
---
  src/channel-display.c   |  2 ++
  src/spice-widget-priv.h |  3 +--
  src/spice-widget.c      | 51 ++++++++++++++++-------------------------
  3 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/src/channel-display.c b/src/channel-display.c
index 6b6a172c..e63fb3bb 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -29,7 +29,9 @@
  #include "spice-session-priv.h"
  #include "channel-display-priv.h"
  #include "decode.h"
+#ifdef HAVE_GSTVIDEO
  #include "gst/gst.h"
+#endif
/**
   * SECTION:channel-display
diff --git a/src/spice-widget-priv.h b/src/spice-widget-priv.h
index 651d306e..0264577d 100644
--- a/src/spice-widget-priv.h
+++ b/src/spice-widget-priv.h
@@ -154,8 +154,7 @@ struct _SpiceDisplayPrivate {
  #endif // HAVE_EGL
      double scroll_delta_y;
  #ifdef HAVE_GSTVIDEO
-    GWeakRef                overlay_element_weak_ref;
-    GstPipeline             *pipeline;
+    GWeakRef overlay_weak_ref;


The indentation is wrong in previous line, see attached patch


  #endif
  };
diff --git a/src/spice-widget.c b/src/spice-widget.c
index ae834204..e78fab4c 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -2119,14 +2119,12 @@ static void unrealize(GtkWidget *widget)
spice_cairo_image_destroy(display);
  #if HAVE_EGL
-    if (display->priv->egl.context_ready)
+    if (display->priv->egl.context_ready) {
          spice_egl_unrealize_display(display);
+    }
  #endif
  #ifdef HAVE_GSTVIDEO
-    SpiceDisplayPrivate *d = display->priv;
-
-    g_weak_ref_set(&d->overlay_element_weak_ref, NULL);
-    g_clear_weak_pointer(&d->pipeline);
+    g_weak_ref_set(&display->priv->overlay_weak_ref, NULL);
  #endif
GTK_WIDGET_CLASS(spice_display_parent_class)->unrealize(widget);
@@ -2556,27 +2554,23 @@ static void queue_draw_area(SpiceDisplay *display, gint x, gint y,
  }
#if defined(HAVE_GSTVIDEO) && defined(GDK_WINDOWING_X11)
-static void gst_sync_bus_call(GstBus *bus, GstMessage *msg, gpointer data)
+static void gst_sync_bus_call(GstBus *bus, GstMessage *msg, SpiceDisplay *display)
  {
      switch(GST_MESSAGE_TYPE(msg)) {
      case GST_MESSAGE_ELEMENT: {
-        if (gst_is_video_overlay_prepare_window_handle_message(msg)) {
-            if (!g_getenv("DISABLE_GSTVIDEOOVERLAY") &&
-                GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
-                SpiceDisplay *display = data;
-                GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(display));
-
-                if (window && gdk_window_ensure_native(window)) {
-                    SpiceDisplayPrivate *d = display->priv;
-                    GstElement *overlay_element;
-
-                    g_weak_ref_set(&d->overlay_element_weak_ref, GST_ELEMENT(GST_MESSAGE_SRC(msg)));
-                    overlay_element = g_weak_ref_get(&d->overlay_element_weak_ref);
-                    gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(overlay_element), (uintptr_t)GDK_WINDOW_XID(window));
-                    gst_video_overlay_handle_events(GST_VIDEO_OVERLAY(overlay_element), false);
-                    gst_object_unref(overlay_element);
-                    return;
-                }
+        if (gst_is_video_overlay_prepare_window_handle_message(msg) &&
+            !g_getenv("DISABLE_GSTVIDEOOVERLAY") &&
+            GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+            GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(display));
+
+            if (window && gdk_window_ensure_native(window)) {
+                SpiceDisplayPrivate *d = display->priv;
+
+                GstVideoOverlay *overlay = GST_VIDEO_OVERLAY(GST_MESSAGE_SRC(msg));
+                g_weak_ref_set(&d->overlay_weak_ref, overlay);
+                gst_video_overlay_set_window_handle(overlay, (uintptr_t)GDK_WINDOW_XID(window));
+                gst_video_overlay_handle_events(overlay, false);
+                return;
              }
          }
          break;
@@ -2588,15 +2582,12 @@ static void gst_sync_bus_call(GstBus *bus, GstMessage *msg, gpointer data)
  }
  #endif
-{
-#ifdef GDK_WINDOWING_X11


Something went wrong with my split, I think these two should removed in previous patch
otherwise it won't apply if you checkout there.


Other than that I'm fine with the changes.

Thanks


  /* This callback should pass to the widget a pointer of the pipeline
   * so that we can set pipeline and overlay related calls from here.
   */
-static gboolean set_overlay(SpiceChannel *channel, void* pipeline_ptr, gpointer data)
+static gboolean set_overlay(SpiceChannel *channel, void* pipeline_ptr, SpiceDisplay *display)
  {
  #if defined(HAVE_GSTVIDEO) && defined(GDK_WINDOWING_X11)
-    SpiceDisplay *display = data;
      SpiceDisplayPrivate *d = display->priv;
/* GstVideoOverlay is currently used only under x */
@@ -2609,11 +2600,9 @@ static gboolean set_overlay(SpiceChannel *channel, void* pipeline_ptr, gpointer
              GstBus *bus;
gtk_stack_set_visible_child_name(d->stack, "gst-area");
-            d->pipeline = pipeline_ptr;
-            g_object_add_weak_pointer(pipeline_ptr, (gpointer*)&(d->pipeline)); // Taking a weak ref although pipeline is not used again
-            bus = gst_pipeline_get_bus(GST_PIPELINE(d->pipeline));
+            bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_ptr));
              gst_bus_enable_sync_message_emission(bus);
-            g_signal_connect (bus, "sync-message", G_CALLBACK (gst_sync_bus_call), data);
+            g_signal_connect(bus, "sync-message", G_CALLBACK(gst_sync_bus_call), display);
              gst_object_unref(bus);
              return true;
          }
>From b1981c4b8b5e86014daf226740f395892effd580 Mon Sep 17 00:00:00 2001
From: Snir Sheriber <ssheribe@xxxxxxxxxx>
Date: Mon, 17 Dec 2018 12:32:47 +0200
Subject: [PATCH] spice-widget-priv: Fix indentation

Signed-off-by: Snir Sheriber <ssheribe@xxxxxxxxxx>
---
 src/spice-widget-priv.h | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/spice-widget-priv.h b/src/spice-widget-priv.h
index 96f6c1d..54bcb95 100644
--- a/src/spice-widget-priv.h
+++ b/src/spice-widget-priv.h
@@ -108,12 +108,12 @@ struct _SpiceDisplayPrivate {
     bool                    keyboard_grab_active;
     bool                    keyboard_have_focus;
 
-    const guint16          *keycode_map;
+    const guint16           *keycode_map;
     size_t                  keycode_maplen;
     uint32_t                key_state[512 / 32];
     int                     key_delayed_scancode;
     guint                   key_delayed_id;
-    SpiceGrabSequence         *grabseq; /* the configured key sequence */
+    SpiceGrabSequence       *grabseq; /* the configured key sequence */
     gboolean                *activeseq; /* the currently pressed keys */
     gboolean                seq_pressed;
     gboolean                keyboard_grab_released;
@@ -132,23 +132,23 @@ struct _SpiceDisplayPrivate {
 #endif
 #if HAVE_EGL
     struct {
-        gboolean            context_ready;
-        gboolean            enabled;
-        EGLSurface          surface;
-        EGLDisplay          display;
-        EGLConfig           conf;
-        EGLContext          ctx;
-        gint                mproj, attr_pos, attr_tex;
-        guint               vbuf_id;
-        guint               tex_id;
-        guint               tex_pointer_id;
-        guint               prog;
-        EGLImageKHR         image;
-        gboolean            call_draw_done;
-        SpiceGlScanout      scanout;
+        gboolean                context_ready;
+        gboolean                enabled;
+        EGLSurface              surface;
+        EGLDisplay              display;
+        EGLConfig               conf;
+        EGLContext              ctx;
+        gint                    mproj, attr_pos, attr_tex;
+        guint                   vbuf_id;
+        guint                   tex_id;
+        guint                   tex_pointer_id;
+        guint                   prog;
+        EGLImageKHR             image;
+        gboolean                call_draw_done;
+        SpiceGlScanout          scanout;
     } egl;
 #endif // HAVE_EGL
-    double scroll_delta_y;
+    double                  scroll_delta_y;
 };
 
 int      spice_cairo_image_create                 (SpiceDisplay *display);
-- 
2.19.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]