diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2019-05-31 15:11:13 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2019-06-09 05:29:12 +0200 |
commit | 6fd4bfee60e93ee29c3e68587ff4665650b31a56 (patch) | |
tree | b652240c29cb55ee280e3670d7d1fd99af81ae38 /avmedia/source/gstreamer | |
parent | 87238627b025ee6aa61378667e56b1769d4460c2 (diff) |
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@posteo.de>
Diffstat (limited to 'avmedia/source/gstreamer')
-rw-r--r-- | avmedia/source/gstreamer/gstplayer.cxx | 34 |
1 files changed, 30 insertions, 4 deletions
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(); |