summaryrefslogtreecommitdiff
path: root/avmedia
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-05-13 16:44:42 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-05-13 16:45:09 +0200
commitde8afb9a2b461da4c81e45a7e185b553a5f4c3e7 (patch)
tree4c793794838aaf10d2510b21510eba4a09bd9f77 /avmedia
parent2527a4d5a7cb1a7086129019a29dc063a3a28f63 (diff)
First cut at reporting missing GStreamer plugins
Change-Id: Ia3cd8a2f0979f2312a70b8ee169fe9d6eef85c81
Diffstat (limited to 'avmedia')
-rw-r--r--avmedia/source/gstreamer/gstplayer.cxx62
1 files changed, 61 insertions, 1 deletions
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 <sal/config.h>
+
+#include <cstddef>
+#include <cstring>
+#include <set>
#include <math.h>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/string.hxx>
-
+#include <vcl/svapp.hxx>
#include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx>
@@ -39,6 +44,9 @@
# define AVMEDIA_GST_PLAYER_SERVICENAME "com.sun.star.media.Player_GStreamer"
#endif
+#include <gst/pbutils/missing-plugins.h>
+#include <gst/pbutils/pbutils.h>
+
#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<OString> 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<char *>(res.getStr()), nullptr};
+ gst_install_plugins_sync(args, nullptr);
+ return 0;
+}
+
+struct TheMissingPluginInstaller:
+ public rtl::Static<MissingPluginInstaller, TheMissingPluginInstaller>
+{};
+
+}
// - 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 ) {