From f826da0fb2fb34d71a5755a78f7bffc3404641df Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 12 Feb 2019 13:39:01 +0100 Subject: [PATCH 1/3] audio-video-properties: Add decoder disabler helper (Re-)add a helper to disable decoders that require windowing environments to even be used while gathering metadata. --- extensions/audio-video-properties/meson.build | 2 + .../totem-gst-helpers.c | 97 +++++++++++++++++++ .../totem-gst-helpers.h | 53 ++++++++++ 3 files changed, 152 insertions(+) create mode 100644 extensions/audio-video-properties/totem-gst-helpers.c create mode 100644 extensions/audio-video-properties/totem-gst-helpers.h diff --git a/extensions/audio-video-properties/meson.build b/extensions/audio-video-properties/meson.build index 4ac5cd87da..0b8dcdc7f0 100644 --- a/extensions/audio-video-properties/meson.build +++ b/extensions/audio-video-properties/meson.build @@ -11,6 +11,7 @@ libtotem_properties_page_sources = files( 'totem-properties-main.c', 'totem-properties-view.c', 'bacon-video-widget-properties.c', + 'totem-gst-helpers.c', ) + resources libtotem_properties_page_deps = [ @@ -35,6 +36,7 @@ test_properties_page_sources = files( 'totem-properties-main.c', 'totem-properties-view.c', 'bacon-video-widget-properties.c', + 'totem-gst-helpers.c', 'test-properties-page.c' ) + resources diff --git a/extensions/audio-video-properties/totem-gst-helpers.c b/extensions/audio-video-properties/totem-gst-helpers.c new file mode 100644 index 0000000000..93b81398c4 --- /dev/null +++ b/extensions/audio-video-properties/totem-gst-helpers.c @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2003-2007 the GStreamer project + * Julien Moutte + * Ronald Bultje + * Copyright (C) 2005-2008 Tim-Philipp Müller + * Copyright (C) 2009 Sebastian Dröge + * Copyright © 2009 Christian Persch + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "totem-gst-helpers.h" + +#include +#include + +void +totem_gst_message_print (GstMessage *msg, + GstElement *play, + const char *filename) +{ + GError *err = NULL; + char *dbg = NULL; + + g_return_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR); + + if (play != NULL) { + g_return_if_fail (filename != NULL); + + GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN_CAST (play), + GST_DEBUG_GRAPH_SHOW_ALL ^ GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS, + filename); + } + + gst_message_parse_error (msg, &err, &dbg); + if (err) { + char *uri; + + g_object_get (play, "uri", &uri, NULL); + GST_ERROR ("message = %s", GST_STR_NULL (err->message)); + GST_ERROR ("domain = %d (%s)", err->domain, + GST_STR_NULL (g_quark_to_string (err->domain))); + GST_ERROR ("code = %d", err->code); + GST_ERROR ("debug = %s", GST_STR_NULL (dbg)); + GST_ERROR ("source = %" GST_PTR_FORMAT, msg->src); + GST_ERROR ("uri = %s", GST_STR_NULL (uri)); + g_free (uri); + + g_error_free (err); + } + g_free (dbg); +} + +/* Disable decoders that require a display environment to work, + * and that might cause crashes */ +void +totem_gst_disable_display_decoders (void) +{ + GstRegistry *registry; + const char *blacklisted_plugins[] = { + "bmcdec", + "vaapi", + "video4linux2" + }; + guint i; + + /* Disable the vaapi plugin as it will not work with the + * fakesink we use: + * See: https://bugzilla.gnome.org/show_bug.cgi?id=700186 and + * https://bugzilla.gnome.org/show_bug.cgi?id=749605 */ + registry = gst_registry_get (); + + for (i = 0; i < G_N_ELEMENTS (blacklisted_plugins); i++) { + GstPlugin *plugin = + gst_registry_find_plugin (registry, + blacklisted_plugins[i]); + if (plugin) + gst_registry_remove_plugin (registry, plugin); + } +} + +/* + * vim: sw=2 ts=8 cindent noai bs=2 + */ diff --git a/extensions/audio-video-properties/totem-gst-helpers.h b/extensions/audio-video-properties/totem-gst-helpers.h new file mode 100644 index 0000000000..edeeb1da6c --- /dev/null +++ b/extensions/audio-video-properties/totem-gst-helpers.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2001,2002,2003,2004,2005 Bastien Nocera + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef HAVE_TOTEM_GST_HELPERS_H +#define HAVE_TOTEM_GST_HELPERS_H + +#define GST_USE_UNSTABLE_API 1 + +#include + +G_BEGIN_DECLS + +/* GstPlayFlags flags from playbin */ +typedef enum { + GST_PLAY_FLAG_VIDEO = (1 << 0), + GST_PLAY_FLAG_AUDIO = (1 << 1), + GST_PLAY_FLAG_TEXT = (1 << 2), + GST_PLAY_FLAG_VIS = (1 << 3), + GST_PLAY_FLAG_SOFT_VOLUME = (1 << 4), + GST_PLAY_FLAG_NATIVE_AUDIO = (1 << 5), + GST_PLAY_FLAG_NATIVE_VIDEO = (1 << 6), + GST_PLAY_FLAG_DOWNLOAD = (1 << 7), + GST_PLAY_FLAG_BUFFERING = (1 << 8), + GST_PLAY_FLAG_DEINTERLACE = (1 << 9), + GST_PLAY_FLAG_SOFT_COLORBALANCE = (1 << 10), + GST_PLAY_FLAG_FORCE_FILTERS = (1 << 11), +} GstPlayFlags; + +void totem_gst_message_print (GstMessage *msg, + GstElement *play, + const char *filename); + +void totem_gst_disable_display_decoders (void); + +G_END_DECLS + +#endif /* HAVE_TOTEM_GST_HELPERS_H */ -- GitLab From 3d9d2ef8d1627d2efe56b6bad5c8f6e540f07ec4 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 12 Feb 2019 13:41:32 +0100 Subject: [PATCH 2/3] audio-video-properties: Use totem_gst_disable_display_decoders() --- extensions/audio-video-properties/test-properties-page.c | 2 ++ extensions/audio-video-properties/totem-properties-main.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/extensions/audio-video-properties/test-properties-page.c b/extensions/audio-video-properties/test-properties-page.c index 124f6db8e3..21be43a345 100644 --- a/extensions/audio-video-properties/test-properties-page.c +++ b/extensions/audio-video-properties/test-properties-page.c @@ -22,6 +22,7 @@ #define GST_USE_UNSTABLE_API 1 #include #include +#include "totem-gst-helpers.h" #include "totem-properties-view.h" static GtkWidget *window, *props, *label; @@ -55,6 +56,7 @@ int main (int argc, char **argv) bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); + totem_gst_disable_display_decoders (); gst_init (&argc, &argv); gtk_init (&argc, &argv); diff --git a/extensions/audio-video-properties/totem-properties-main.c b/extensions/audio-video-properties/totem-properties-main.c index 576198ea84..2bbd520c36 100644 --- a/extensions/audio-video-properties/totem-properties-main.c +++ b/extensions/audio-video-properties/totem-properties-main.c @@ -26,6 +26,7 @@ #include #include "totem-properties-view.h" +#include "totem-gst-helpers.h" #include #define WANT_MIME_TYPES 1 @@ -76,6 +77,7 @@ static gpointer init_backend (gpointer data) { gst_init (NULL, NULL); + totem_gst_disable_display_decoders (); return NULL; } -- GitLab From c51899c3558cd41d425e0d38f3cb4371e1e69f02 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 12 Feb 2019 13:45:28 +0100 Subject: [PATCH 3/3] audio-video-properties: Remove unused code --- .../totem-gst-helpers.c | 41 +------------------ .../totem-gst-helpers.h | 28 ------------- 2 files changed, 1 insertion(+), 68 deletions(-) diff --git a/extensions/audio-video-properties/totem-gst-helpers.c b/extensions/audio-video-properties/totem-gst-helpers.c index 93b81398c4..e01996dafa 100644 --- a/extensions/audio-video-properties/totem-gst-helpers.c +++ b/extensions/audio-video-properties/totem-gst-helpers.c @@ -23,46 +23,7 @@ */ #include "totem-gst-helpers.h" - -#include -#include - -void -totem_gst_message_print (GstMessage *msg, - GstElement *play, - const char *filename) -{ - GError *err = NULL; - char *dbg = NULL; - - g_return_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR); - - if (play != NULL) { - g_return_if_fail (filename != NULL); - - GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN_CAST (play), - GST_DEBUG_GRAPH_SHOW_ALL ^ GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS, - filename); - } - - gst_message_parse_error (msg, &err, &dbg); - if (err) { - char *uri; - - g_object_get (play, "uri", &uri, NULL); - GST_ERROR ("message = %s", GST_STR_NULL (err->message)); - GST_ERROR ("domain = %d (%s)", err->domain, - GST_STR_NULL (g_quark_to_string (err->domain))); - GST_ERROR ("code = %d", err->code); - GST_ERROR ("debug = %s", GST_STR_NULL (dbg)); - GST_ERROR ("source = %" GST_PTR_FORMAT, msg->src); - GST_ERROR ("uri = %s", GST_STR_NULL (uri)); - g_free (uri); - - g_error_free (err); - } - g_free (dbg); -} +#include /* Disable decoders that require a display environment to work, * and that might cause crashes */ diff --git a/extensions/audio-video-properties/totem-gst-helpers.h b/extensions/audio-video-properties/totem-gst-helpers.h index edeeb1da6c..9ec559cae9 100644 --- a/extensions/audio-video-properties/totem-gst-helpers.h +++ b/extensions/audio-video-properties/totem-gst-helpers.h @@ -20,34 +20,6 @@ #ifndef HAVE_TOTEM_GST_HELPERS_H #define HAVE_TOTEM_GST_HELPERS_H -#define GST_USE_UNSTABLE_API 1 - -#include - -G_BEGIN_DECLS - -/* GstPlayFlags flags from playbin */ -typedef enum { - GST_PLAY_FLAG_VIDEO = (1 << 0), - GST_PLAY_FLAG_AUDIO = (1 << 1), - GST_PLAY_FLAG_TEXT = (1 << 2), - GST_PLAY_FLAG_VIS = (1 << 3), - GST_PLAY_FLAG_SOFT_VOLUME = (1 << 4), - GST_PLAY_FLAG_NATIVE_AUDIO = (1 << 5), - GST_PLAY_FLAG_NATIVE_VIDEO = (1 << 6), - GST_PLAY_FLAG_DOWNLOAD = (1 << 7), - GST_PLAY_FLAG_BUFFERING = (1 << 8), - GST_PLAY_FLAG_DEINTERLACE = (1 << 9), - GST_PLAY_FLAG_SOFT_COLORBALANCE = (1 << 10), - GST_PLAY_FLAG_FORCE_FILTERS = (1 << 11), -} GstPlayFlags; - -void totem_gst_message_print (GstMessage *msg, - GstElement *play, - const char *filename); - void totem_gst_disable_display_decoders (void); -G_END_DECLS - #endif /* HAVE_TOTEM_GST_HELPERS_H */ -- GitLab