diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-05-23 17:09:51 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-05-27 10:27:02 +0200 |
commit | 9d18bc40416b651340804f44ba5fae65f3bbbcfa (patch) | |
tree | 30fda9ba61854d5e5e0036dd1f883b911cf7b9ad /avmedia/source/gstreamer | |
parent | b1501d65674a74481b61a10a250febed77348f4a (diff) |
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@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'avmedia/source/gstreamer')
-rw-r--r-- | avmedia/source/gstreamer/gstplayer.cxx | 55 | ||||
-rw-r--r-- | avmedia/source/gstreamer/gstplayer.hxx | 1 |
2 files changed, 51 insertions, 5 deletions
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; |