Kaydet (Commit) de8afb9a authored tarafından Stephan Bergmann's avatar Stephan Bergmann

First cut at reporting missing GStreamer plugins

Change-Id: Ia3cd8a2f0979f2312a70b8ee169fe9d6eef85c81
üst 2527a4d5
...@@ -17,12 +17,17 @@ ...@@ -17,12 +17,17 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * 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 <math.h>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
#include <rtl/string.hxx> #include <rtl/string.hxx>
#include <vcl/svapp.hxx>
#include <vcl/syschild.hxx> #include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx> #include <vcl/sysdata.hxx>
...@@ -39,6 +44,9 @@ ...@@ -39,6 +44,9 @@
# define AVMEDIA_GST_PLAYER_SERVICENAME "com.sun.star.media.Player_GStreamer" # define AVMEDIA_GST_PLAYER_SERVICENAME "com.sun.star.media.Player_GStreamer"
#endif #endif
#include <gst/pbutils/missing-plugins.h>
#include <gst/pbutils/pbutils.h>
#if !defined DBG #if !defined DBG
# if OSL_DEBUG_LEVEL > 2 # if OSL_DEBUG_LEVEL > 2
#ifdef AVMEDIA_GST_0_10 #ifdef AVMEDIA_GST_0_10
...@@ -56,6 +64,56 @@ using namespace ::com::sun::star; ...@@ -56,6 +64,56 @@ using namespace ::com::sun::star;
namespace avmedia { namespace gstreamer { 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 - // - Player -
...@@ -328,6 +386,8 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message ) ...@@ -328,6 +386,8 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message )
} }
} }
#endif #endif
} else if (gst_is_missing_plugin_message(message)) {
TheMissingPluginInstaller::get().report(message);
} else if( GST_MESSAGE_TYPE( message ) == GST_MESSAGE_ERROR ) { } else if( GST_MESSAGE_TYPE( message ) == GST_MESSAGE_ERROR ) {
DBG( "Error !\n" ); DBG( "Error !\n" );
if( mnWidth == 0 ) { if( mnWidth == 0 ) {
......
...@@ -10220,7 +10220,7 @@ if test "$build_gstreamer_1_0" = "yes"; then ...@@ -10220,7 +10220,7 @@ if test "$build_gstreamer_1_0" = "yes"; then
if test "$enable_avmedia" = yes -a "$enable_gstreamer_1_0" != no; then if test "$enable_avmedia" = yes -a "$enable_gstreamer_1_0" != no; then
ENABLE_GSTREAMER_1_0="TRUE" ENABLE_GSTREAMER_1_0="TRUE"
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
PKG_CHECK_MODULES( [GSTREAMER_1_0], [gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-video-1.0] ) PKG_CHECK_MODULES( [GSTREAMER_1_0], [gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0] )
GSTREAMER_1_0_CFLAGS=$(printf '%s' "$GSTREAMER_1_0_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g") GSTREAMER_1_0_CFLAGS=$(printf '%s' "$GSTREAMER_1_0_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
else else
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
...@@ -10238,8 +10238,8 @@ if test "$build_gstreamer_0_10" = "yes"; then ...@@ -10238,8 +10238,8 @@ if test "$build_gstreamer_0_10" = "yes"; then
if test "$enable_avmedia" = yes -a "$enable_gstreamer_0_10" != no; then if test "$enable_avmedia" = yes -a "$enable_gstreamer_0_10" != no; then
ENABLE_GSTREAMER_0_10="TRUE" ENABLE_GSTREAMER_0_10="TRUE"
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
PKG_CHECK_MODULES( [GSTREAMER_0_10], [gstreamer-0.10 gstreamer-plugins-base-0.10 gstreamer-interfaces-0.10],, [ PKG_CHECK_MODULES( [GSTREAMER_0_10], [gstreamer-0.10 gstreamer-plugins-base-0.10 gstreamer-pbutils-0.10 gstreamer-interfaces-0.10],, [
PKG_CHECK_MODULES( [GSTREAMER_0_10], [gstreamer-0.10 gstreamer-plugins-base-0.10] ) PKG_CHECK_MODULES( [GSTREAMER_0_10], [gstreamer-0.10 gstreamer-plugins-base-0.10 gstreamer-pbutils-0.10] )
]) ])
GSTREAMER_0_10_CFLAGS=$(printf '%s' "$GSTREAMER_0_10_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g") GSTREAMER_0_10_CFLAGS=$(printf '%s' "$GSTREAMER_0_10_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
else else
......
...@@ -482,6 +482,7 @@ certain functionality. ...@@ -482,6 +482,7 @@ certain functionality.
@section avmedia @section avmedia
@li @c avmedia @li @c avmedia
@li @c avmedia.gstreamer
@li @c avmedia.opengl - OpenGL models @li @c avmedia.opengl - OpenGL models
@section other @section other
......
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