Kaydet (Commit) 9d18bc40 authored tarafından Caolán McNamara's avatar Caolán McNamara

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/72871Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst b1501d65
......@@ -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);
......
......@@ -95,6 +95,7 @@ private:
bool mbLooping;
bool mbInitialized;
void* mpDisplay;
long mnWindowID;
GstVideoOverlay* mpXOverlay;
gint64 mnDuration;
......
......@@ -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
{
}
......
......@@ -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);
}
......
......@@ -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()
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment