[Libreoffice-commits] core.git: avmedia/source include/vcl vcl/qt5 vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon May 27 08:28:00 UTC 2019


 avmedia/source/gstreamer/gstplayer.cxx |   55 ++++++++++++++++++++++++++++++---
 avmedia/source/gstreamer/gstplayer.hxx |    1 
 include/vcl/sysdata.hxx                |    2 +
 vcl/qt5/Qt5Frame.cxx                   |   18 +++++++++-
 vcl/qt5/Qt5Object.cxx                  |   19 ++++++++++-
 vcl/unx/gtk/gtkobject.cxx              |    1 
 vcl/unx/gtk/gtksalframe.cxx            |    1 
 vcl/unx/gtk3/gtk3gtkframe.cxx          |    8 ++++
 vcl/unx/gtk3/gtk3gtkobject.cxx         |    8 ++++
 9 files changed, 104 insertions(+), 9 deletions(-)

New commits:
commit 9d18bc40416b651340804f44ba5fae65f3bbbcfa
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu May 23 17:09:51 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon May 27 10:27:02 2019 +0200

    tdf#125271 under wayland without gtksink, try waylandsink
    
    and if there is no videosink then give up
    
    Change-Id: I6b60e7be1e77dbf5c4c277ccf47a4d121f3cd6a5
    Reviewed-on: https://gerrit.libreoffice.org/72871
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx
index 6303bc53bb68..b2e5382353f9 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -302,6 +302,7 @@ Player::Player() :
     mbMuted( false ),
     mbLooping( false ),
     mbInitialized( false ),
+    mpDisplay( nullptr ),
     mnWindowID( 0 ),
     mpXOverlay( nullptr ),
     mnDuration( 0 ),
@@ -453,6 +454,31 @@ static gboolean wrap_element_query_duration (GstElement *element, GstFormat form
 #endif
 }
 
+#ifndef AVMEDIA_GST_0_10
+
+#define LCL_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE "GstWaylandDisplayHandleContextType"
+
+static gboolean lcl_is_wayland_display_handle_need_context_message(GstMessage* msg)
+{
+    g_return_val_if_fail(GST_IS_MESSAGE(msg), false);
+
+    if (GST_MESSAGE_TYPE(msg) != GST_MESSAGE_NEED_CONTEXT)
+        return false;
+    const gchar *type = nullptr;
+    if (!gst_message_parse_context_type(msg, &type))
+        return false;
+    return !g_strcmp0(type, LCL_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE);
+}
+
+static GstContext* lcl_wayland_display_handle_context_new(void* display)
+{
+    GstContext *context = gst_context_new(LCL_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE, TRUE);
+    gst_structure_set (gst_context_writable_structure (context),
+                       "handle", G_TYPE_POINTER, display, nullptr);
+    return context;
+}
+
+#endif
 
 GstBusSyncReply Player::processSyncMessage( GstMessage *message )
 {
@@ -498,6 +524,15 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message )
 
             return GST_BUS_DROP;
         }
+#ifndef AVMEDIA_GST_0_10
+        else if (lcl_is_wayland_display_handle_need_context_message(message))
+        {
+            GstContext *context = lcl_wayland_display_handle_context_new(mpDisplay);
+            gst_element_set_context(GST_ELEMENT(GST_MESSAGE_SRC(message)), context);
+
+            return GST_BUS_DROP;
+        }
+#endif
     }
 
 #ifdef AVMEDIA_GST_0_10
@@ -896,7 +931,6 @@ awt::Size SAL_CALL Player::getPreferredPlayerWindowSize()
     return aSize;
 }
 
-
 uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& rArguments )
 {
     ::osl::MutexGuard aGuard(m_aMutex);
@@ -931,6 +965,7 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
             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
@@ -945,9 +980,10 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
                     }
                 }
 
+                GstElement *pVideosink = nullptr;
 #if defined(ENABLE_GTKSINK)
-                GstElement *pVideosink = (aToolkit == "gtk3") ?
-                                           gst_element_factory_make("gtksink", "gtksink") : nullptr;
+                pVideosink = (aToolkit == "gtk3") ?
+                              gst_element_factory_make("gtksink", "gtksink") : nullptr;
                 if (pVideosink)
                 {
                     mbUseGtkSink = true;
@@ -965,14 +1001,24 @@ 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 (!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 );
                 }
-
             }
         }
     }
@@ -980,7 +1026,6 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
     return xRet;
 }
 
-
 uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber()
 {
     ::osl::MutexGuard aGuard(m_aMutex);
diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx
index b39521025da3..c57f60a7802f 100644
--- a/avmedia/source/gstreamer/gstplayer.hxx
+++ b/avmedia/source/gstreamer/gstplayer.hxx
@@ -95,6 +95,7 @@ private:
     bool                    mbLooping;
     bool                    mbInitialized;
 
+    void*                   mpDisplay;
     long                    mnWindowID;
     GstVideoOverlay*        mpXOverlay;
     gint64                  mnDuration;
diff --git a/include/vcl/sysdata.hxx b/include/vcl/sysdata.hxx
index 5c42207649d0..4b7b562da519 100644
--- a/include/vcl/sysdata.hxx
+++ b/include/vcl/sysdata.hxx
@@ -72,6 +72,7 @@ struct SystemEnvData
     // however, the GTK3 vclplug wants to store pointers in here!
     sal_IntPtr          aShellWindow;   // the window of the frame's shell
     const char*         pToolkit;       // the toolkit in use (gtk2 vs gtk3)
+    const char*         pPlatformName; // the windowing system in use (xcb vs wayland)
 #endif
 
     SystemEnvData()
@@ -92,6 +93,7 @@ struct SystemEnvData
         , nScreen(0)
         , aShellWindow(0)
         , pToolkit(nullptr)
+        , pPlatformName(nullptr)
 #endif
     {
     }
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 41a4544b4acb..4c39086957ea 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -162,16 +162,28 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo)
     // s. https://doc.qt.io/qt-5/qwidget.html#native-widgets-vs-alien-widgets
     // Avoid this on Wayland due to problems with missing 'mouseMoveEvent's,
     // s. tdf#122293/QTBUG-75766
-    if (QGuiApplication::platformName() != "wayland")
+    const bool bWayland = QGuiApplication::platformName() == "wayland";
+    if (!bWayland)
         m_aSystemData.aWindow = m_pQWidget->winId();
-    // TODO implement as needed for Wayland,
-    // s.a. commit c0d4f3ad3307c which did this for gtk3
+    else
+    {
+        // TODO implement as needed for Wayland,
+        // s.a. commit c0d4f3ad3307c which did this for gtk3
+        // QPlatformNativeInterface* native = QGuiApplication::platformNativeInterface();
+        // m_aSystemData.pDisplay = native->nativeResourceForWindow("display", nullptr);
+        // m_aSystemData.aWindow = reinterpret_cast<unsigned long>(
+        //     native->nativeResourceForWindow("surface", m_pQWidget->windowHandle()));
+    }
 
     m_aSystemData.aShellWindow = reinterpret_cast<sal_IntPtr>(this);
     //m_aSystemData.pSalFrame = this;
     //m_aSystemData.pWidget = m_pQWidget;
     //m_aSystemData.nScreen = m_nXScreen.getXScreen();
     m_aSystemData.pToolkit = "qt5";
+    if (!bWayland)
+        m_aSystemData.pPlatformName = "xcb";
+    else
+        m_aSystemData.pPlatformName = "wayland";
 
     SetIcon(SV_ICON_ID_OFFICE);
 }
diff --git a/vcl/qt5/Qt5Object.cxx b/vcl/qt5/Qt5Object.cxx
index 0f3a4f29750a..deae5e2ad831 100644
--- a/vcl/qt5/Qt5Object.cxx
+++ b/vcl/qt5/Qt5Object.cxx
@@ -23,6 +23,7 @@
 #include <Qt5Frame.hxx>
 
 #include <QtWidgets/QWidget>
+#include <QtGui/QGuiApplication>
 #include <QtGui/QWindow>
 
 Qt5Object::Qt5Object(Qt5Frame* pParent, bool bShow)
@@ -40,12 +41,28 @@ Qt5Object::Qt5Object(Qt5Frame* pParent, bool bShow)
         m_pQWidget->show();
 
     m_aSystemData.nSize = sizeof(SystemEnvData);
-    m_aSystemData.aWindow = m_pQWindow->winId(); // ID of the embedded window
     m_aSystemData.aShellWindow = reinterpret_cast<sal_IntPtr>(this);
     //m_aSystemData.pSalFrame = this;
     //m_aSystemData.pWidget = m_pQWidget;
     //m_aSystemData.nScreen = m_nXScreen.getXScreen();
     m_aSystemData.pToolkit = "qt5";
+    m_aSystemData.pPlatformName = "xcb";
+    const bool bWayland = QGuiApplication::platformName() == "wayland";
+    if (!bWayland)
+    {
+        m_aSystemData.pPlatformName = "xcb";
+        m_aSystemData.aWindow = m_pQWindow->winId(); // ID of the embedded window
+    }
+    else
+    {
+        m_aSystemData.pPlatformName = "wayland";
+        // TODO implement as needed for Wayland,
+        // s.a. commit c0d4f3ad3307c which did this for gtk3
+        // QPlatformNativeInterface* native = QGuiApplication::platformNativeInterface();
+        // m_aSystemData.pDisplay = native->nativeResourceForWindow("display", nullptr);
+        // m_aSystemData.aWindow = reinterpret_cast<unsigned long>(
+        //     native->nativeResourceForWindow("surface", m_pQWidget->windowHandle()));
+    }
 }
 
 void Qt5Object::ResetClipRegion()
diff --git a/vcl/unx/gtk/gtkobject.cxx b/vcl/unx/gtk/gtkobject.cxx
index dd7ad722b4c7..38302c60ef74 100644
--- a/vcl/unx/gtk/gtkobject.cxx
+++ b/vcl/unx/gtk/gtkobject.cxx
@@ -61,6 +61,7 @@ GtkSalObject::GtkSalObject( GtkSalFrame* pParent, bool bShow )
     m_aSystemData.pWidget       = m_pSocket;
     m_aSystemData.nScreen       = pParent->getXScreenNumber().getXScreen();
     m_aSystemData.pToolkit      = "gtk2";
+    m_aSystemData.pPlatformName = "xcb";
 
     g_signal_connect( G_OBJECT(m_pSocket), "button-press-event", G_CALLBACK(signalButton), this );
     g_signal_connect( G_OBJECT(m_pSocket), "button-release-event", G_CALLBACK(signalButton), this );
diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
index 75be17dcddc9..3316bc0705e6 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -841,6 +841,7 @@ void GtkSalFrame::InitCommon()
     m_aSystemData.pWidget       = m_pWindow;
     m_aSystemData.nScreen       = m_nXScreen.getXScreen();
     m_aSystemData.pToolkit      = "gtk2";
+    m_aSystemData.pPlatformName = "xcb";
 
     m_bGraphics = false;
     m_pGraphics = nullptr;
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index d16db67057e5..27d186923b6f 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -961,6 +961,14 @@ void GtkSalFrame::InitCommon()
     {
         m_aSystemData.pDisplay = gdk_x11_display_get_xdisplay(pDisplay);
         m_aSystemData.pVisual = gdk_x11_visual_get_xvisual(pVisual);
+        m_aSystemData.pPlatformName = "xcb";
+    }
+#endif
+#if defined(GDK_WINDOWING_WAYLAND)
+    if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay))
+    {
+        m_aSystemData.pDisplay = gdk_wayland_display_get_wl_display(pDisplay);
+        m_aSystemData.pPlatformName = "wayland";
     }
 #endif
 
diff --git a/vcl/unx/gtk3/gtk3gtkobject.cxx b/vcl/unx/gtk3/gtk3gtkobject.cxx
index a92913f110fb..04db858a3ade 100644
--- a/vcl/unx/gtk3/gtk3gtkobject.cxx
+++ b/vcl/unx/gtk3/gtk3gtkobject.cxx
@@ -64,6 +64,14 @@ GtkSalObject::GtkSalObject( GtkSalFrame* pParent, bool bShow )
     {
         m_aSystemData.pDisplay = gdk_x11_display_get_xdisplay(pDisplay);
         m_aSystemData.pVisual = gdk_x11_visual_get_xvisual(pVisual);
+        m_aSystemData.pPlatformName = "xcb";
+    }
+#endif
+#if defined(GDK_WINDOWING_WAYLAND)
+    if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay))
+    {
+        m_aSystemData.pDisplay = gdk_wayland_display_get_wl_display(pDisplay);
+        m_aSystemData.pPlatformName = "wayland";
     }
 #endif
 


More information about the Libreoffice-commits mailing list