[Libreoffice-commits] core.git: avmedia/Library_avmediagst.mk avmedia/source vcl/qt5

Michael Weghorn (via logerrit) logerrit at kemper.freedesktop.org
Sun Jun 9 03:30:12 UTC 2019


 avmedia/Library_avmediagst.mk          |   10 +++++++++
 avmedia/source/gstreamer/gstplayer.cxx |   34 +++++++++++++++++++++++++++++----
 vcl/qt5/Qt5Frame.cxx                   |    2 -
 vcl/qt5/Qt5Object.cxx                  |    2 -
 4 files changed, 42 insertions(+), 6 deletions(-)

New commits:
commit 6fd4bfee60e93ee29c3e68587ff4665650b31a56
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: Sun Jun 9 05:29:12 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
    
    Change-Id: I6e17838dcdf5c31a1a8a07f7836a4cf36c63bd06
    Reviewed-on: https://gerrit.libreoffice.org/72968
    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 07b58898e070..570a6fe02fe5 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -42,6 +42,10 @@
 #include "gstframegrabber.hxx"
 #include "gstwindow.hxx"
 
+#if ENABLE_QT5
+#include <QtWidgets/QWidget>
+#endif
+
 #include <gst/video/videooverlay.h>
 #define AVMEDIA_GST_PLAYER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Player_GStreamer"
 #define AVMEDIA_GST_PLAYER_SERVICENAME        "com.sun.star.media.Player_GStreamer"
@@ -908,10 +912,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
+                    // 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 0520465c190e..8e63a35cc5c8 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -197,7 +197,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 deae5e2ad831..a635a5931886 100644
--- a/vcl/qt5/Qt5Object.cxx
+++ b/vcl/qt5/Qt5Object.cxx
@@ -43,7 +43,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";


More information about the Libreoffice-commits mailing list