summaryrefslogtreecommitdiff
path: root/avmedia
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-06-10 21:40:33 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2019-06-13 23:45:09 +0200
commita6201725d760cbce832d4de029b418bb7334df6a (patch)
tree5fcb76c6179ba382b078f0a127427dc429c18109 /avmedia
parent2d36e43d3d3ac69f4cacd532308cfc8c81982864 (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 'avmedia')
-rw-r--r--avmedia/Library_avmediagst.mk20
-rw-r--r--avmedia/source/gstreamer/gstplayer.cxx161
-rw-r--r--avmedia/source/gstreamer/gstplayer.hxx9
3 files changed, 52 insertions, 138 deletions
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 f88addd0cfef..35feb8ad5ea2 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -42,10 +42,6 @@
#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"
@@ -287,9 +283,6 @@ Player::Player() :
GstPlayer_BASE( m_aMutex ),
mpPlaybin( nullptr ),
mpVolumeControl( nullptr ),
-#if ENABLE_GTK3
- mpGtkWidget( nullptr ),
-#endif
mbUseGtkSink( false ),
mbFakeVideo (false ),
mnUnmutedVolume( 0 ),
@@ -347,14 +340,6 @@ void SAL_CALL Player::disposing()
// Release the elements and pipeline
if( mbInitialized )
{
-#if ENABLE_GTK3
- if (mpGtkWidget)
- {
- gtk_widget_destroy(mpGtkWidget);
- mpGtkWidget = nullptr;
- }
-#endif
-
if( mpPlaybin )
{
gst_element_set_state( mpPlaybin, GST_STATE_NULL );
@@ -557,14 +542,6 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message )
void Player::preparePlaybin( const OUString& rURL, GstElement *pSink )
{
-#if ENABLE_GTK3
- if (mpGtkWidget)
- {
- gtk_widget_destroy(mpGtkWidget);
- mpGtkWidget = nullptr;
- }
-#endif
-
if (mpPlaybin != nullptr)
{
gst_element_set_state( mpPlaybin, GST_STATE_NULL );
@@ -870,98 +847,64 @@ 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;
+
+ const SystemEnvData* pEnvData = pParentWindow->GetSystemData();
+ if (!pEnvData)
+ return nullptr;
+
+ OUString aToolkit = OUString::createFromAscii(pEnvData->pToolkit);
+ OUString aPlatform = OUString::createFromAscii(pEnvData->pPlatformName);
- if( rArguments.getLength() > 2 )
+ // 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")
{
- sal_IntPtr pIntPtr = 0;
- rArguments[ 2 ] >>= pIntPtr;
- SystemChildWindow *pParentWindow = reinterpret_cast< SystemChildWindow* >( pIntPtr );
+ Point aPoint = pParentWindow->GetPosPixel();
+ maArea.X = aPoint.getX();
+ maArea.Y = aPoint.getY();
+ }
- 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();
- }
- }
+ mbUseGtkSink = false;
- GstElement *pVideosink = nullptr;
-#if ENABLE_GTK3
- 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
- // 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 its 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();
- 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 );
- }
- }
+ 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 9bc0e3eb4cb5..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
-# 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
- GtkWidget* mpGtkWidget;
-#endif
bool mbUseGtkSink;
bool mbFakeVideo;