From de8afb9a2b461da4c81e45a7e185b553a5f4c3e7 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 13 May 2015 16:44:42 +0200 Subject: First cut at reporting missing GStreamer plugins Change-Id: Ia3cd8a2f0979f2312a70b8ee169fe9d6eef85c81 --- avmedia/source/gstreamer/gstplayer.cxx | 62 +++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'avmedia') diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx index 1b06c174e759..eea5bb66400b 100644 --- a/avmedia/source/gstreamer/gstplayer.cxx +++ b/avmedia/source/gstreamer/gstplayer.cxx @@ -17,12 +17,17 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include +#include +#include #include #include #include - +#include #include #include @@ -39,6 +44,9 @@ # define AVMEDIA_GST_PLAYER_SERVICENAME "com.sun.star.media.Player_GStreamer" #endif +#include +#include + #if !defined DBG # if OSL_DEBUG_LEVEL > 2 #ifdef AVMEDIA_GST_0_10 @@ -56,6 +64,56 @@ using namespace ::com::sun::star; namespace avmedia { namespace gstreamer { +namespace { + +class MissingPluginInstaller { +public: + void report(GstMessage * message); + +private: + DECL_STATIC_LINK(MissingPluginInstaller, install, rtl_String *); + + std::set reported_; +}; + +void MissingPluginInstaller::report(GstMessage * message) { + // assert(gst_is_missing_plugin_message(message)); + gchar * det = gst_missing_plugin_message_get_installer_detail(message); + if (det != nullptr) { + std::size_t len = std::strlen(det); + if (len <= sal_uInt32(SAL_MAX_INT32)) { + OString detStr(det, len); + if (reported_.insert(detStr).second) { + rtl_string_acquire(detStr.pData); + Application::PostUserEvent( + LINK(nullptr, MissingPluginInstaller, install), + detStr.pData); + } + } else { + SAL_WARN( + "avmedia.gstreamer", "detail string too long"); + } + g_free(det); + } else { + SAL_WARN( + "avmedia.gstreamer", + "gst_missing_plugin_message_get_installer_detail failed"); + } +} + +IMPL_STATIC_LINK(MissingPluginInstaller, install, rtl_String *, data) { + OString res(data, SAL_NO_ACQUIRE); + gst_pb_utils_init(); // not thread safe + char * args[]{const_cast(res.getStr()), nullptr}; + gst_install_plugins_sync(args, nullptr); + return 0; +} + +struct TheMissingPluginInstaller: + public rtl::Static +{}; + +} // - Player - @@ -328,6 +386,8 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message ) } } #endif + } else if (gst_is_missing_plugin_message(message)) { + TheMissingPluginInstaller::get().report(message); } else if( GST_MESSAGE_TYPE( message ) == GST_MESSAGE_ERROR ) { DBG( "Error !\n" ); if( mnWidth == 0 ) { -- cgit