diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-06-10 21:40:33 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-06-13 23:45:09 +0200 |
commit | a6201725d760cbce832d4de029b418bb7334df6a (patch) | |
tree | 5fcb76c6179ba382b078f0a127427dc429c18109 /vcl | |
parent | 2d36e43d3d3ac69f4cacd532308cfc8c81982864 (diff) |
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.
Change-Id: I693947e441bceb4b09bc38920e308e39142d0a35
Reviewed-on: https://gerrit.libreoffice.org/73849
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/Library_vclplug_gtk3.mk | 1 | ||||
-rw-r--r-- | vcl/Library_vclplug_gtk3_kde5.mk | 1 | ||||
-rw-r--r-- | vcl/Library_vclplug_qt5.mk | 7 | ||||
-rw-r--r-- | vcl/inc/qt5/Qt5Instance.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/salinst.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/unx/gstsink.hxx | 27 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkinst.hxx | 4 | ||||
-rw-r--r-- | vcl/qt5/Qt5Instance.cxx | 38 | ||||
-rw-r--r-- | vcl/source/window/syschild.cxx | 5 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 33 |
10 files changed, 117 insertions, 4 deletions
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 cfd370221dde..d67c53e2a6f5 100644 --- a/vcl/Library_vclplug_gtk3_kde5.mk +++ b/vcl/Library_vclplug_gtk3_kde5.mk @@ -36,6 +36,7 @@ $(eval $(call gb_Library_add_cxxflags,vclplug_gtk3_kde5,\ $$(INCLUDE) \ $$(GTK3_CFLAGS) \ $(KF5_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 1a0546488bcd..c1aaccea84c8 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),) +ifneq ($(QT5_HAVE_GOBJECT),) $(eval $(call gb_Library_add_cxxflags,vclplug_qt5,\ - $(QT5_GLIB_CFLAGS) \ + $(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 c87f3c93c1ac..6c4afd328ee2 100644 --- a/vcl/inc/qt5/Qt5Instance.hxx +++ b/vcl/inc/qt5/Qt5Instance.hxx @@ -151,6 +151,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 db1ae606a593..51b0347f3247 100644 --- a/vcl/inc/salinst.hxx +++ b/vcl/inc/salinst.hxx @@ -50,6 +50,7 @@ namespace weld { class Widget; class Window; } +class SystemChildWindow; struct SystemParentData; struct SalPrinterQueueInfo; class ImplJobSetup; @@ -206,6 +207,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 52061f8b5ea1..ae5de33b3cd5 100644 --- a/vcl/qt5/Qt5Instance.cxx +++ b/vcl/qt5/Qt5Instance.cxx @@ -48,7 +48,7 @@ #include <comphelper/flagguard.hxx> #include <sal/log.hxx> #include <osl/process.h> - +#include <unx/gstsink.hxx> #include <headless/svpbmp.hxx> #include <mutex> @@ -488,6 +488,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 ec1f6d4e28bd..42a66e69b460 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> @@ -10778,4 +10779,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: */ |