[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - 3 commits - avmedia/Library_avmediagst.mk avmedia/source config_host/config_vclplug.h.in config_host.mk.in configure.ac include/vcl vcl/inc vcl/Library_vclplug_gtk3_kde5.mk vcl/Library_vclplug_gtk3.mk vcl/Library_vclplug_qt5.mk vcl/qt5 vcl/source vcl/unx

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 25 18:54:18 UTC 2019


 avmedia/Library_avmediagst.mk          |   11 --
 avmedia/source/gstreamer/gstplayer.cxx |  136 ++++++++++++---------------------
 avmedia/source/gstreamer/gstplayer.hxx |    7 -
 config_host.mk.in                      |    6 -
 config_host/config_vclplug.h.in        |    2 
 configure.ac                           |   30 +++----
 include/vcl/syschild.hxx               |    2 
 vcl/Library_vclplug_gtk3.mk            |    1 
 vcl/Library_vclplug_gtk3_kde5.mk       |    1 
 vcl/Library_vclplug_qt5.mk             |    9 +-
 vcl/inc/qt5/Qt5Instance.hxx            |    2 
 vcl/inc/salinst.hxx                    |    3 
 vcl/inc/unx/gstsink.hxx                |   27 ++++++
 vcl/inc/unx/gtk/gtkinst.hxx            |    4 
 vcl/qt5/Qt5Frame.cxx                   |    2 
 vcl/qt5/Qt5Instance.cxx                |   38 ++++++++-
 vcl/qt5/Qt5Object.cxx                  |    2 
 vcl/source/window/syschild.cxx         |    5 +
 vcl/unx/gtk3/gtk3gtkinst.cxx           |   33 ++++++++
 19 files changed, 195 insertions(+), 126 deletions(-)

New commits:
commit 819671b662c441087f6f3a363cae27491e5344d9
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Mon Jun 10 21:40:33 2019 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Tue Jun 25 20:53:50 2019 +0200

    Don't link avmediagst with gtk3 and qt5
    
    While the VCL plugins are dynamically loaded and therefore just
    load their depending toolkit libraries, the GStreamer avmedia
    backend now links against Qt and GTK+. The GStreamer API itself
    is toolkit agnostic and the toolkit setup just uses a single
    GStreamer symbol to create the specific video sink.
    
    So the toolkit binding can simply be moved into the VCL plugin.
    At the point of the GStreamer toolkit setup call the GStreamer
    library is loaded by avmediagst, so the dlsym lookup should
    never fail.
    
    I also dropped the special GtkWidget handling. Using g_object_get
    will increase the refcount of the widget. A g_object_unref after
    adding it to the container seems to destroy it correctly.
    
    Reviewed-on: https://gerrit.libreoffice.org/73849
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
    (cherry picked from commit a6201725d760cbce832d4de029b418bb7334df6a)
    
    Change-Id: I693947e441bceb4b09bc38920e308e39142d0a35
    Reviewed-on: https://gerrit.libreoffice.org/74652
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/avmedia/Library_avmediagst.mk b/avmedia/Library_avmediagst.mk
index 027123911e87..7ed6cc451a24 100644
--- a/avmedia/Library_avmediagst.mk
+++ b/avmedia/Library_avmediagst.mk
@@ -21,26 +21,6 @@ $(eval $(call gb_Library_add_libs,avmediagst,\
     $(GSTREAMER_1_0_LIBS) \
 ))
 
-ifneq ($(ENABLE_GTK3),)
-$(eval $(call gb_Library_add_cxxflags,avmediagst,\
-    $$(GTK3_CFLAGS) \
-))
-
-$(eval $(call gb_Library_add_libs,avmediagst,\
-    $(GTK3_LIBS) \
-))
-endif
-
-ifneq ($(ENABLE_QT5),)
-$(eval $(call gb_Library_add_cxxflags,avmediagst,\
-    $$(QT5_CFLAGS) \
-))
-
-$(eval $(call gb_Library_add_libs,avmediagst,\
-    $(QT5_LIBS) \
-))
-endif
-
 $(eval $(call gb_Library_use_external,avmediagst,boost_headers))
 
 $(eval $(call gb_Library_use_sdk_api,avmediagst))
diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx
index 3f727ed8e7e4..0236f7895b8c 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -51,10 +51,6 @@
 #  define AVMEDIA_GST_PLAYER_SERVICENAME        "com.sun.star.media.Player_GStreamer"
 #endif
 
-#if ENABLE_QT5 && ! defined (AVMEDIA_GST_0_10)
-#include <QtWidgets/QWidget>
-#endif
-
 #include <gst/pbutils/missing-plugins.h>
 #include <gst/pbutils/pbutils.h>
 
@@ -296,9 +292,6 @@ Player::Player() :
     GstPlayer_BASE( m_aMutex ),
     mpPlaybin( nullptr ),
     mpVolumeControl( nullptr ),
-#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
-    mpGtkWidget( nullptr ),
-#endif
     mbUseGtkSink( false ),
     mbFakeVideo (false ),
     mnUnmutedVolume( 0 ),
@@ -356,14 +349,6 @@ void SAL_CALL Player::disposing()
     // Release the elements and pipeline
     if( mbInitialized )
     {
-#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
-        if (mpGtkWidget)
-        {
-            gtk_widget_destroy(mpGtkWidget);
-            mpGtkWidget = nullptr;
-        }
-#endif
-
         if( mpPlaybin )
         {
             gst_element_set_state( mpPlaybin, GST_STATE_NULL );
@@ -646,14 +631,6 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message )
 
 void Player::preparePlaybin( const OUString& rURL, GstElement *pSink )
 {
-#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
-    if (mpGtkWidget)
-    {
-        gtk_widget_destroy(mpGtkWidget);
-        mpGtkWidget = nullptr;
-    }
-#endif
-
     if (mpPlaybin != nullptr)
     {
         gst_element_set_state( mpPlaybin, GST_STATE_NULL );
@@ -963,98 +940,63 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
     if( aSize.Width > 0 && aSize.Height > 0 )
     {
         ::avmedia::gstreamer::Window* pWindow = new ::avmedia::gstreamer::Window;
+        if (rArguments.getLength() <= 2)
+        {
+            xRet = pWindow;
+            return xRet;
+        }
 
-        xRet = pWindow;
+        sal_IntPtr pIntPtr = 0;
+        rArguments[ 2 ] >>= pIntPtr;
+        SystemChildWindow *pParentWindow = reinterpret_cast< SystemChildWindow* >( pIntPtr );
+        if (!pParentWindow)
+            return nullptr;
 
-        if( rArguments.getLength() > 2 )
-        {
-            sal_IntPtr pIntPtr = 0;
-            rArguments[ 2 ] >>= pIntPtr;
-            SystemChildWindow *pParentWindow = reinterpret_cast< SystemChildWindow* >( pIntPtr );
+        const SystemEnvData* pEnvData = pParentWindow->GetSystemData();
+        if (!pEnvData)
+            return nullptr;
 
-            const SystemEnvData* pEnvData = pParentWindow ? pParentWindow->GetSystemData() : nullptr;
-            OSL_ASSERT(pEnvData);
-            if (pEnvData)
-            {
-                OUString aToolkit = OUString::createFromAscii(pEnvData->pToolkit);
-                OUString aPlatform = OUString::createFromAscii(pEnvData->pPlatformName);
-
-                // tdf#124027: the position of embedded window is identical w/ the position
-                // of media object in all other vclplugs (gtk, kde5, gen), in gtk3 w/o gtksink it
-                // needs to be translated
-                if (aToolkit == "gtk3")
-                {
-                    if (pParentWindow)
-                    {
-                        Point aPoint = pParentWindow->GetPosPixel();
-                        maArea.X = aPoint.getX();
-                        maArea.Y = aPoint.getY();
-                    }
-                }
+        OUString aToolkit = OUString::createFromAscii(pEnvData->pToolkit);
+        OUString aPlatform = OUString::createFromAscii(pEnvData->pPlatformName);
 
-                GstElement *pVideosink = nullptr;
-#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
-                pVideosink = (aToolkit == "gtk3") ?
-                              gst_element_factory_make("gtksink", "gtksink") : nullptr;
-                if (pVideosink)
-                {
-                    mbUseGtkSink = true;
-                    g_object_get(pVideosink, "widget", &mpGtkWidget, nullptr);
-                    gtk_widget_set_vexpand(mpGtkWidget, true);
-                    gtk_widget_set_hexpand(mpGtkWidget, true);
-                    GtkWidget *pParent = static_cast<GtkWidget*>(pEnvData->pWidget);
-                    gtk_container_add (GTK_CONTAINER(pParent), mpGtkWidget);
-
-                    g_object_set( G_OBJECT( mpPlaybin ), "video-sink", pVideosink, nullptr);
-                    g_object_set( G_OBJECT( mpPlaybin ), "force-aspect-ratio", FALSE, nullptr);
-
-                    gtk_widget_show_all (pParent);
-                }
-                else
-#endif
-                {
-#if ENABLE_QT5 && ! defined (AVMEDIA_GST_0_10)
-                    // try to use qwidget5videosink for qt5 on Wayland, which requires the Qt5 packages for QtGStreamer to be installed
-                    if (aToolkit == "qt5" && aPlatform == "wayland")
-                    {
-                        pVideosink = gst_element_factory_make("qwidget5videosink", "qwidget5videosink");
-                        if (pVideosink) {
-                            QWidget* pQWidget = static_cast<QWidget*>(pEnvData->pWidget);
-                            g_object_set(G_OBJECT(pVideosink), "widget", pQWidget, nullptr);
-                        }
-                        else
-                        {
-                            SAL_WARN("avmedia.gstreamer", "Couldn't initialize qwidget5videosink."
-                                                          " Video playback might not work as expected."
-                                                          " Please install Qt5 packages for QtGStreamer.");
-                            // with no videosink explicitly set, GStreamer will open it's own (misplaced) window(s) to display video
-                        }
-                    }
-#endif
-                    if (!pVideosink)
-                    {
-                        if (aPlatform == "wayland")
-                            pVideosink = gst_element_factory_make("waylandsink", "video-output");
-                        else
-                            pVideosink = gst_element_factory_make("autovideosink", "video-output");
-                    }
+        // tdf#124027: the position of embedded window is identical w/ the position
+        // of media object in all other vclplugs (gtk, kde5, gen), in gtk3 w/o gtksink it
+        // needs to be translated
+        if (aToolkit == "gtk3")
+        {
+            Point aPoint = pParentWindow->GetPosPixel();
+            maArea.X = aPoint.getX();
+            maArea.Y = aPoint.getY();
+        }
 
-                    if (!pVideosink)
-                    {
-                        xRet.clear();
-                        return nullptr;
-                    }
-                    g_object_set(G_OBJECT(mpPlaybin), "video-sink", pVideosink, nullptr);
-                    mbUseGtkSink = false;
-                    mnWindowID = pEnvData->aWindow;
-                    mpDisplay = pEnvData->pDisplay;
-                    SAL_INFO( "avmedia.gstreamer", AVVERSION "set window id to " << static_cast<int>(mnWindowID) << " XOverlay " << mpXOverlay);
-                    gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
-                    if ( mpXOverlay != nullptr )
-                        gst_video_overlay_set_window_handle( mpXOverlay, mnWindowID );
-                }
-            }
+        mbUseGtkSink = false;
+        GstElement *pVideosink = static_cast<GstElement*>(pParentWindow->CreateGStreamerSink());
+        if (pVideosink)
+        {
+            if (aToolkit == "gtk3")
+                mbUseGtkSink = true;
         }
+        else
+        {
+            if (aPlatform == "wayland")
+                pVideosink = gst_element_factory_make("waylandsink", "video-output");
+            else
+                pVideosink = gst_element_factory_make("autovideosink", "video-output");
+            if (!pVideosink)
+                return nullptr;
+        }
+
+        xRet = pWindow;
+
+        g_object_set(G_OBJECT(mpPlaybin), "video-sink", pVideosink, nullptr);
+        g_object_set(G_OBJECT(mpPlaybin), "force-aspect-ratio", FALSE, nullptr);
+
+        mnWindowID = pEnvData->aWindow;
+        mpDisplay = pEnvData->pDisplay;
+        SAL_INFO( "avmedia.gstreamer", AVVERSION "set window id to " << static_cast<int>(mnWindowID) << " XOverlay " << mpXOverlay);
+        gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
+        if ( mpXOverlay != nullptr )
+            gst_video_overlay_set_window_handle( mpXOverlay, mnWindowID );
     }
 
     return xRet;
diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx
index b7a18205ff17..67aabb998d7a 100644
--- a/avmedia/source/gstreamer/gstplayer.hxx
+++ b/avmedia/source/gstreamer/gstplayer.hxx
@@ -20,8 +20,6 @@
 #ifndef INCLUDED_AVMEDIA_SOURCE_GSTREAMER_GSTPLAYER_HXX
 #define INCLUDED_AVMEDIA_SOURCE_GSTREAMER_GSTPLAYER_HXX
 
-#include <config_vclplug.h>
-
 #include <osl/conditn.hxx>
 #include "gstcommon.hxx"
 
@@ -29,10 +27,6 @@
 #include <cppuhelper/compbase.hxx>
 #include <cppuhelper/basemutex.hxx>
 
-#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
-#    include <gtk/gtk.h>
-#endif
-
 typedef struct _GstVideoOverlay GstVideoOverlay;
 
 namespace avmedia { namespace gstreamer {
@@ -85,9 +79,6 @@ private:
     // Add elements and pipeline here
     GstElement*             mpPlaybin;  // the playbin is also a pipeline
     GstElement*             mpVolumeControl;  // the playbin is also a pipeline
-#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
-    GtkWidget*              mpGtkWidget;
-#endif
     bool                    mbUseGtkSink;
     bool                    mbFakeVideo;
 
diff --git a/config_host.mk.in b/config_host.mk.in
index 90bb4e37c891..af6d0c43b60d 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -469,9 +469,9 @@ export PYTHON_VERSION_MAJOR=@PYTHON_VERSION_MAJOR@
 export PYTHON_VERSION_MINOR=@PYTHON_VERSION_MINOR@
 export QT5_CFLAGS=$(gb_SPACE)@QT5_CFLAGS@
 export QT5_LIBS=$(gb_SPACE)@QT5_LIBS@
-export QT5_GLIB_CFLAGS=$(gb_SPACE)@QT5_GLIB_CFLAGS@
-export QT5_GLIB_LIBS=$(gb_SPACE)@QT5_GLIB_LIBS@
-export QT5_HAVE_GLIB=@QT5_HAVE_GLIB@
+export QT5_GOBJECT_CFLAGS=$(gb_SPACE)@QT5_GOBJECT_CFLAGS@
+export QT5_GOBJECT_LIBS=$(gb_SPACE)@QT5_GOBJECT_LIBS@
+export QT5_HAVE_GOBJECT=@QT5_HAVE_GOBJECT@
 export QXP_CFLAGS=$(gb_SPACE)@QXP_CFLAGS@
 export QXP_LIBS=$(gb_SPACE)@QXP_LIBS@
 export RANLIB=@RANLIB@
diff --git a/config_host/config_vclplug.h.in b/config_host/config_vclplug.h.in
index 5245a1ea7fb2..418beaf23cd0 100644
--- a/config_host/config_vclplug.h.in
+++ b/config_host/config_vclplug.h.in
@@ -14,5 +14,7 @@ Settings about which desktops have support enabled.
 #define ENABLE_QT5 0
 
 #define QT5_USING_X11 0
+#define QT5_HAVE_GOBJECT 0
+#define ENABLE_GSTREAMER_1_0 0
 
 #endif
diff --git a/configure.ac b/configure.ac
index fd7805b07031..35d472134a60 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10621,6 +10621,7 @@ if test "$build_gstreamer_1_0" = "yes"; then
         GSTREAMER_1_0_CFLAGS=$(printf '%s' "$GSTREAMER_1_0_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
         FilterLibs "${GSTREAMER_1_0_LIBS}"
         GSTREAMER_1_0_LIBS="${filteredlibs}"
+        AC_DEFINE(ENABLE_GSTREAMER_1_0)
     else
         AC_MSG_RESULT([no])
     fi
@@ -11205,9 +11206,9 @@ QT5_CFLAGS=""
 QT5_LIBS=""
 QMAKE5="qmake"
 MOC5="moc"
-QT5_GLIB_CFLAGS=""
-QT5_GLIB_LIBS=""
-QT5_HAVE_GLIB=""
+QT5_GOBJECT_CFLAGS=""
+QT5_GOBJECT_LIBS=""
+QT5_HAVE_GOBJECT=""
 if test \( "$test_kde5" = "yes" -a "$ENABLE_KDE5" = "TRUE" \) -o \
         \( "$test_qt5" = "yes" -a "$ENABLE_QT5" = "TRUE" \) -o \
         \( "$test_gtk3_kde5" = "yes" -a "$ENABLE_GTK3_KDE5" = "TRUE" \)
@@ -11289,21 +11290,22 @@ then
 the root of your Qt installation by exporting QT5DIR before running "configure".])
     fi
 
-    # Glib is needed for properly handling Qt event loop with Qt's Glib integration enabled.
-    # Sets also QT5_GLIB_CFLAGS/QT5_GLIB_LIBS if successful.
-    PKG_CHECK_MODULES(QT5_GLIB,[glib-2.0 >= 2.4],
-        [
-            QT5_HAVE_GLIB=1
-        ],
-        AC_MSG_WARN([[No Glib found, Qt5 support will not use native file pickers!]])
-    )
+
+    if test "$build_gstreamer_1_0" = "yes"; then
+        PKG_CHECK_MODULES(QT5_GOBJECT,[gobject-2.0], [
+                QT5_HAVE_GOBJECT=1
+                AC_DEFINE(QT5_HAVE_GOBJECT)
+            ],
+            AC_MSG_WARN([[No GObject found, can't use QWidget GStreamer sink on wayland!]])
+        )
+    fi
 fi
 AC_SUBST(QT5_CFLAGS)
 AC_SUBST(QT5_LIBS)
 AC_SUBST(MOC5)
-AC_SUBST(QT5_GLIB_CFLAGS)
-AC_SUBST(QT5_GLIB_LIBS)
-AC_SUBST(QT5_HAVE_GLIB)
+AC_SUBST(QT5_GOBJECT_CFLAGS)
+AC_SUBST(QT5_GOBJECT_LIBS)
+AC_SUBST(QT5_HAVE_GOBJECT)
 
 dnl ===================================================================
 dnl KDE5 Integration
diff --git a/include/vcl/syschild.hxx b/include/vcl/syschild.hxx
index 9f5be6780064..e15295e79a78 100644
--- a/include/vcl/syschild.hxx
+++ b/include/vcl/syschild.hxx
@@ -57,6 +57,8 @@ public:
     void                    SetLeaveEnterBackgrounds(const css::uno::Sequence<css::uno::Any>& rLeaveArgs, const css::uno::Sequence<css::uno::Any>& rEnterArgs);
     // return the platform specific handle/id of this window;
     sal_IntPtr              GetParentWindowHandle();
+
+    void*                   CreateGStreamerSink();
 };
 
 #endif // INCLUDED_VCL_SYSCHILD_HXX
diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk
index a77f3b300ad6..c0ad6cd21e52 100644
--- a/vcl/Library_vclplug_gtk3.mk
+++ b/vcl/Library_vclplug_gtk3.mk
@@ -28,6 +28,7 @@ $(eval $(call gb_Library_add_cxxflags,vclplug_gtk3, \
 $(eval $(call gb_Library_set_include,vclplug_gtk3,\
     $$(INCLUDE) \
     $$(GTK3_CFLAGS) \
+    $$(GSTREAMER_1_0_CFLAGS) \
     -I$(SRCDIR)/vcl/inc \
     -I$(SRCDIR)/vcl/unx \
     -I$(SRCDIR)/vcl/unx/gtk3 \
diff --git a/vcl/Library_vclplug_gtk3_kde5.mk b/vcl/Library_vclplug_gtk3_kde5.mk
index 089d6ee31a1f..0da97df5fdfd 100644
--- a/vcl/Library_vclplug_gtk3_kde5.mk
+++ b/vcl/Library_vclplug_gtk3_kde5.mk
@@ -35,6 +35,7 @@ $(eval $(call gb_Library_set_include,vclplug_gtk3_kde5,\
 $(eval $(call gb_Library_add_cxxflags,vclplug_gtk3_kde5,\
     $$(INCLUDE) \
     $$(GTK3_CFLAGS) \
+    $$(GSTREAMER_1_0_CFLAGS) \
 ))
 
 $(eval $(call gb_Library_add_defs,vclplug_gtk3_kde5,\
diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk
index 3231672c8743..18e2b6f22e7b 100644
--- a/vcl/Library_vclplug_qt5.mk
+++ b/vcl/Library_vclplug_qt5.mk
@@ -25,6 +25,7 @@ $(eval $(call gb_Library_set_include,vclplug_qt5,\
     $$(INCLUDE) \
     -I$(SRCDIR)/vcl/inc \
     -I$(SRCDIR)/vcl/inc/qt5 \
+    $(GSTREAMER_1_0_CFLAGS) \
 ))
 
 $(eval $(call gb_Library_add_defs,vclplug_qt5,\
@@ -70,12 +71,12 @@ $(eval $(call gb_Library_add_libs,vclplug_qt5,\
     $(QT5_LIBS) \
 ))
 
-ifneq ($(QT5_HAVE_GLIB),)
-$(eval $(call gb_Library_add_defs,vclplug_qt5,\
-    $(QT5_GLIB_CFLAGS) \
+ifneq ($(QT5_HAVE_GOBJECT),)
+$(eval $(call gb_Library_add_cxxflags,vclplug_qt5,\
+    $(QT5_GOBJECT_CFLAGS) \
 ))
 $(eval $(call gb_Library_add_libs,vclplug_qt5,\
-    $(QT5_GLIB_LIBS) \
+    $(QT5_GOBJECT_LIBS) \
 ))
 endif
 
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index 69d871a6368c..2411cdb7f52c 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -152,6 +152,8 @@ public:
     virtual css::uno::Reference<css::uno::XInterface> CreateDropTarget() override;
 
     void UpdateStyle(bool bFontsChanged);
+
+    void* CreateGStreamerSink(const SystemChildWindow*) override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index 4acb0315de4c..93121c2e01f8 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -52,6 +52,7 @@ namespace weld {
     class Widget;
     class Window;
 }
+class SystemChildWindow;
 struct SystemParentData;
 struct SalPrinterQueueInfo;
 class ImplJobSetup;
@@ -208,6 +209,8 @@ public:
     virtual OUString        getOSVersion() { return OUString("-"); }
 
     virtual const cairo_font_options_t* GetCairoFontOptions() { return nullptr; }
+
+    virtual void* CreateGStreamerSink(const SystemChildWindow*) { return nullptr; }
 };
 
 // called from SVMain
diff --git a/vcl/inc/unx/gstsink.hxx b/vcl/inc/unx/gstsink.hxx
new file mode 100644
index 000000000000..2dff94b02c12
--- /dev/null
+++ b/vcl/inc/unx/gstsink.hxx
@@ -0,0 +1,27 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <config_vclplug.h>
+
+#if ENABLE_GSTREAMER_1_0
+#include <gst/gst.h>
+#include <dlfcn.h>
+
+typedef GstElement* (*GstElementFactoryName)(const gchar*, const gchar*);
+
+static GstElementFactoryName gstElementFactoryNameSymbol()
+{
+    return reinterpret_cast<GstElementFactoryName>(dlsym(nullptr, "gst_element_factory_make"));
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index c0e073cca845..cc2455a42eb8 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -254,6 +254,10 @@ public:
 
     std::shared_ptr<vcl::unx::GtkPrintWrapper> const & getPrintWrapper() const;
 
+#if GTK_CHECK_VERSION(3,0,0)
+    void* CreateGStreamerSink(const SystemChildWindow*) override;
+#endif
+
 private:
     GtkSalTimer *m_pTimer;
 #if GTK_CHECK_VERSION(3,0,0)
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 0494720b5740..f0818c08be7e 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -47,7 +47,7 @@
 #include <comphelper/flagguard.hxx>
 #include <sal/log.hxx>
 #include <osl/process.h>
-
+#include <unx/gstsink.hxx>
 #include <headless/svpbmp.hxx>
 
 #include <mutex>
@@ -497,6 +497,42 @@ void Qt5Instance::UpdateStyle(bool bFontsChanged)
         m_aUpdateStyleTimer.Start();
 }
 
+void* Qt5Instance::CreateGStreamerSink(const SystemChildWindow* pWindow)
+{
+#if ENABLE_GSTREAMER_1_0 && QT5_HAVE_GOBJECT
+    auto pSymbol = gstElementFactoryNameSymbol();
+    if (!pSymbol)
+        return nullptr;
+
+    const SystemEnvData* pEnvData = pWindow->GetSystemData();
+    if (!pEnvData)
+        return nullptr;
+
+    OUString aPlatform = OUString::createFromAscii(pEnvData->pPlatformName);
+    if (aPlatform != "wayland")
+        return nullptr;
+
+    GstElement* pVideosink = pSymbol("qwidget5videosink", "qwidget5videosink");
+    if (pVideosink)
+    {
+        QWidget* pQWidget = static_cast<QWidget*>(pEnvData->pWidget);
+        g_object_set(G_OBJECT(pVideosink), "widget", pQWidget, nullptr);
+    }
+    else
+    {
+        SAL_WARN("vcl.qt5", "Couldn't initialize qwidget5videosink."
+                            " Video playback might not work as expected."
+                            " Please install Qt5 packages for QtGStreamer.");
+        // with no videosink explicitly set, GStreamer will open it's own (misplaced) window(s) to display video
+    }
+
+    return pVideosink;
+#else
+    (void*)pWindow;
+    return nullptr;
+#endif
+}
+
 void Qt5Instance::AllocFakeCmdlineArgs(std::unique_ptr<char* []>& rFakeArgv,
                                        std::unique_ptr<int>& rFakeArgc,
                                        std::vector<FreeableCStr>& rFakeArgvFreeable)
diff --git a/vcl/source/window/syschild.cxx b/vcl/source/window/syschild.cxx
index e6f3e6013400..e7beacdf608c 100644
--- a/vcl/source/window/syschild.cxx
+++ b/vcl/source/window/syschild.cxx
@@ -185,4 +185,9 @@ sal_IntPtr SystemChildWindow::GetParentWindowHandle()
     return nRet;
 }
 
+void* SystemChildWindow::CreateGStreamerSink()
+{
+    return ImplGetSVData()->mpDefInst->CreateGStreamerSink(this);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index d92b36ad428c..caa1510af7e6 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -36,6 +36,7 @@
 #include <tools/fract.hxx>
 #include <tools/stream.hxx>
 #include <unotools/resmgr.hxx>
+#include <unx/gstsink.hxx>
 #include <vcl/ImageTree.hxx>
 #include <vcl/i18nhelp.hxx>
 #include <vcl/quickselectionengine.hxx>
@@ -10861,4 +10862,36 @@ weld::Window* GtkSalFrame::GetFrameWeld() const
     return m_xFrameWeld.get();
 }
 
+void* GtkInstance::CreateGStreamerSink(const SystemChildWindow *pWindow)
+{
+#if ENABLE_GSTREAMER_1_0
+    auto aSymbol = gstElementFactoryNameSymbol();
+    if (!aSymbol)
+        return nullptr;
+
+    const SystemEnvData* pEnvData = pWindow->GetSystemData();
+    if (!pEnvData)
+        return nullptr;
+
+    GstElement* pVideosink = aSymbol("gtksink", "gtksink");
+    if (!pVideosink)
+        return nullptr;
+
+    GtkWidget *pGstWidget;
+    g_object_get(pVideosink, "widget", &pGstWidget, nullptr);
+    gtk_widget_set_vexpand(pGstWidget, true);
+    gtk_widget_set_hexpand(pGstWidget, true);
+
+    GtkWidget *pParent = static_cast<GtkWidget*>(pEnvData->pWidget);
+    gtk_container_add(GTK_CONTAINER(pParent), pGstWidget);
+    g_object_unref(pGstWidget);
+    gtk_widget_show_all(pParent);
+
+    return pVideosink;
+#else
+    (void*)pWindow;
+    return nullptr;
+#endif
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit cc4051bddd7bad2ba28f9e827e6d75f0aacb6649
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Fri May 31 15:11:13 2019 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Tue Jun 25 20:53:43 2019 +0200

    tdf#125219 qt5: Try qwidget5videosink on Wayland
    
    Try to use GStreamer's qwidget5videosink when using the
    qt5 (or kde5) VCL plugin on Wayland.
    
    This is strongly inspired by commit
    8543fbc72fafc0d71a8760752ca2ef5b7119cb5c
    ("gtk3+wayland: play video via gtksink gstreamer element").
    
    qwidget5videosink allows to directly set a 'QWidget*'
    for the sink's "widget" property to make it paint into this
    widget, s. [1] for more details.
    
    In order for this to work, the relevant Qt5 packages for
    QtGStreamer need to be installed (provided e.g. by package
    'qtgstreamer-plugins-qt5' on Debian). If qwidget5videosink
    is available, video playback works as expected on Wayland.
    
    If it is not available, GStreamer will create it's own
    (misplaced) window(s) to show the video as is the case without
    this commit.
    
    Switching to e.g. qtglvideosink in the future may theoretically
    improve performance, since that one uses OpenGL/OpenGLES and
    supports hardware colorspace conversion and color balance, while
    qwidgetvideosink does software painting (s. [1]).
    
    Also, extending commit 9d18bc40416b651340804f44ba5fae65f3bbbcfa
    ("tdf#125271 under wayland without gtksink, try waylandsink") to
    also work with (i.e. set the right window for) waylandsink on
    qt5 may be worth to take a look at in the future, but didn't
    "just work" in a quick attempt.
    
    [1] https://gstreamer.freedesktop.org/data/doc/gstreamer/head/qt-gstreamer/html/qtvideosink_overview.html
    
    Reviewed-on: https://gerrit.libreoffice.org/72968
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
    (cherry picked from commit 6fd4bfee60e93ee29c3e68587ff4665650b31a56)
    
    Change-Id: I6e17838dcdf5c31a1a8a07f7836a4cf36c63bd06
    Reviewed-on: https://gerrit.libreoffice.org/74651
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/avmedia/Library_avmediagst.mk b/avmedia/Library_avmediagst.mk
index cd651c82e60b..027123911e87 100644
--- a/avmedia/Library_avmediagst.mk
+++ b/avmedia/Library_avmediagst.mk
@@ -31,6 +31,16 @@ $(eval $(call gb_Library_add_libs,avmediagst,\
 ))
 endif
 
+ifneq ($(ENABLE_QT5),)
+$(eval $(call gb_Library_add_cxxflags,avmediagst,\
+    $$(QT5_CFLAGS) \
+))
+
+$(eval $(call gb_Library_add_libs,avmediagst,\
+    $(QT5_LIBS) \
+))
+endif
+
 $(eval $(call gb_Library_use_external,avmediagst,boost_headers))
 
 $(eval $(call gb_Library_use_sdk_api,avmediagst))
diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx
index 1fd480504236..3f727ed8e7e4 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -51,6 +51,10 @@
 #  define AVMEDIA_GST_PLAYER_SERVICENAME        "com.sun.star.media.Player_GStreamer"
 #endif
 
+#if ENABLE_QT5 && ! defined (AVMEDIA_GST_0_10)
+#include <QtWidgets/QWidget>
+#endif
+
 #include <gst/pbutils/missing-plugins.h>
 #include <gst/pbutils/pbutils.h>
 
@@ -1009,10 +1013,32 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
                 else
 #endif
                 {
-                    if (aPlatform == "wayland")
-                        pVideosink = gst_element_factory_make("waylandsink", "video-output");
-                    else
-                        pVideosink = gst_element_factory_make("autovideosink", "video-output");
+#if ENABLE_QT5 && ! defined (AVMEDIA_GST_0_10)
+                    // try to use qwidget5videosink for qt5 on Wayland, which requires the Qt5 packages for QtGStreamer to be installed
+                    if (aToolkit == "qt5" && aPlatform == "wayland")
+                    {
+                        pVideosink = gst_element_factory_make("qwidget5videosink", "qwidget5videosink");
+                        if (pVideosink) {
+                            QWidget* pQWidget = static_cast<QWidget*>(pEnvData->pWidget);
+                            g_object_set(G_OBJECT(pVideosink), "widget", pQWidget, nullptr);
+                        }
+                        else
+                        {
+                            SAL_WARN("avmedia.gstreamer", "Couldn't initialize qwidget5videosink."
+                                                          " Video playback might not work as expected."
+                                                          " Please install Qt5 packages for QtGStreamer.");
+                            // with no videosink explicitly set, GStreamer will open it's own (misplaced) window(s) to display video
+                        }
+                    }
+#endif
+                    if (!pVideosink)
+                    {
+                        if (aPlatform == "wayland")
+                            pVideosink = gst_element_factory_make("waylandsink", "video-output");
+                        else
+                            pVideosink = gst_element_factory_make("autovideosink", "video-output");
+                    }
+
                     if (!pVideosink)
                     {
                         xRet.clear();
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index da3dc665379e..f17ae82c819e 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -185,7 +185,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
 
     m_aSystemData.aShellWindow = reinterpret_cast<sal_IntPtr>(this);
     //m_aSystemData.pSalFrame = this;
-    //m_aSystemData.pWidget = m_pQWidget;
+    m_aSystemData.pWidget = m_pQWidget;
     //m_aSystemData.nScreen = m_nXScreen.getXScreen();
     m_aSystemData.pToolkit = "qt5";
     if (!bWayland)
diff --git a/vcl/qt5/Qt5Object.cxx b/vcl/qt5/Qt5Object.cxx
index a0afe811a40c..961622eeb893 100644
--- a/vcl/qt5/Qt5Object.cxx
+++ b/vcl/qt5/Qt5Object.cxx
@@ -44,7 +44,7 @@ Qt5Object::Qt5Object(Qt5Frame* pParent, bool bShow)
     m_aSystemData.nSize = sizeof(SystemEnvData);
     m_aSystemData.aShellWindow = reinterpret_cast<sal_IntPtr>(this);
     //m_aSystemData.pSalFrame = this;
-    //m_aSystemData.pWidget = m_pQWidget;
+    m_aSystemData.pWidget = m_pQWidget;
     //m_aSystemData.nScreen = m_nXScreen.getXScreen();
     m_aSystemData.pToolkit = "qt5";
     m_aSystemData.pPlatformName = "xcb";
commit 817e7f7f2e468070802b3176f3deb7f4a88c6c31
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Fri May 31 13:26:32 2019 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Tue Jun 25 20:53:36 2019 +0200

    Drop extra define ENABLE_GTKSINK
    
    Directly use 'ENABLE_GTK3' instead, s.a. discussion at
    https://gerrit.libreoffice.org/#/c/72968/ .
    
    Reviewed-on: https://gerrit.libreoffice.org/73270
    Tested-by: Jenkins
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
    (cherry picked from commit 34bbf192a7753205bb64d14e4eec4ce303317396)
    
    Change-Id: I9713cd942e3f7308974eebc432dce0d2bc5adadc
    Reviewed-on: https://gerrit.libreoffice.org/74650
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/avmedia/Library_avmediagst.mk b/avmedia/Library_avmediagst.mk
index 9b9622b7edc5..cd651c82e60b 100644
--- a/avmedia/Library_avmediagst.mk
+++ b/avmedia/Library_avmediagst.mk
@@ -24,7 +24,6 @@ $(eval $(call gb_Library_add_libs,avmediagst,\
 ifneq ($(ENABLE_GTK3),)
 $(eval $(call gb_Library_add_cxxflags,avmediagst,\
     $$(GTK3_CFLAGS) \
-    -DENABLE_GTKSINK \
 ))
 
 $(eval $(call gb_Library_add_libs,avmediagst,\
diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx
index 250f924f5096..1fd480504236 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -292,7 +292,7 @@ Player::Player() :
     GstPlayer_BASE( m_aMutex ),
     mpPlaybin( nullptr ),
     mpVolumeControl( nullptr ),
-#if defined(ENABLE_GTKSINK)
+#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
     mpGtkWidget( nullptr ),
 #endif
     mbUseGtkSink( false ),
@@ -352,7 +352,7 @@ void SAL_CALL Player::disposing()
     // Release the elements and pipeline
     if( mbInitialized )
     {
-#if defined(ENABLE_GTKSINK)
+#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
         if (mpGtkWidget)
         {
             gtk_widget_destroy(mpGtkWidget);
@@ -642,7 +642,7 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message )
 
 void Player::preparePlaybin( const OUString& rURL, GstElement *pSink )
 {
-#if defined(ENABLE_GTKSINK)
+#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
     if (mpGtkWidget)
     {
         gtk_widget_destroy(mpGtkWidget);
@@ -989,7 +989,7 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
                 }
 
                 GstElement *pVideosink = nullptr;
-#if defined(ENABLE_GTKSINK)
+#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
                 pVideosink = (aToolkit == "gtk3") ?
                               gst_element_factory_make("gtksink", "gtksink") : nullptr;
                 if (pVideosink)
diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx
index c57f60a7802f..b7a18205ff17 100644
--- a/avmedia/source/gstreamer/gstplayer.hxx
+++ b/avmedia/source/gstreamer/gstplayer.hxx
@@ -20,6 +20,8 @@
 #ifndef INCLUDED_AVMEDIA_SOURCE_GSTREAMER_GSTPLAYER_HXX
 #define INCLUDED_AVMEDIA_SOURCE_GSTREAMER_GSTPLAYER_HXX
 
+#include <config_vclplug.h>
+
 #include <osl/conditn.hxx>
 #include "gstcommon.hxx"
 
@@ -27,7 +29,7 @@
 #include <cppuhelper/compbase.hxx>
 #include <cppuhelper/basemutex.hxx>
 
-#if defined(ENABLE_GTKSINK)
+#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
 #    include <gtk/gtk.h>
 #endif
 
@@ -83,7 +85,7 @@ private:
     // Add elements and pipeline here
     GstElement*             mpPlaybin;  // the playbin is also a pipeline
     GstElement*             mpVolumeControl;  // the playbin is also a pipeline
-#if defined(ENABLE_GTKSINK)
+#if ENABLE_GTK3 && ! defined (AVMEDIA_GST_0_10)
     GtkWidget*              mpGtkWidget;
 #endif
     bool                    mbUseGtkSink;


More information about the Libreoffice-commits mailing list