[totem/wip/hadess/add-sw-rendering: 7/9] gst: Simplify disabling hardware decoders




commit 61027f0ad85d67fd6ab4c34161f03b8a9aac21de
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Feb 15 11:26:11 2022 +0100

    gst: Simplify disabling hardware decoders
    
    Take inspiration from the playbin2 code to disable hardware decoders to
    disable all "Hardware" decoders.

 src/gst/totem-gst-helpers.c | 64 ++++++++++++++++++++++-----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)
---
diff --git a/src/gst/totem-gst-helpers.c b/src/gst/totem-gst-helpers.c
index 293dfe0c7..212910da5 100644
--- a/src/gst/totem-gst-helpers.c
+++ b/src/gst/totem-gst-helpers.c
@@ -72,43 +72,43 @@ totem_gst_message_print (GstMessage *msg,
   g_free (dbg);
 }
 
+static gboolean
+filter_hw_decoders (GstPluginFeature *feature,
+                   gpointer          user_data)
+{
+  GstElementFactory *factory;
+
+  if (!GST_IS_ELEMENT_FACTORY (feature))
+    return FALSE;
+
+  factory = GST_ELEMENT_FACTORY (feature);
+  if (!gst_element_factory_list_is_type (factory,
+                                        GST_ELEMENT_FACTORY_TYPE_DECODER |
+                                        GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO |
+                                        GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE)) {
+    return FALSE;
+  }
+
+  return gst_element_factory_list_is_type (factory,
+                                          GST_ELEMENT_FACTORY_TYPE_HARDWARE);
+}
+
 /* 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 *blocked_plugins[] = {
-         "bmcdec",
-         "vaapi",
-         "video4linux2",
-         "nvmpegvideodec",
-         "nvmpeg2videodec",
-         "nvmpeg4videodec",
-         "nvh264sldec",
-         "nvh264dec",
-         "nvjpegdec",
-         "nvh265sldec",
-         "nvh265dec",
-         "nvvp8dec",
-       };
-       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
-        *      https://bugzilla.gnome.org/show_bug.cgi?id=749605
-        *      
https://gitlab.gnome.org/GNOME/tracker-miners/-/commit/1d3accb9187611629c9be3727c729809d96d9ea6
-        */
-       registry = gst_registry_get ();
-
-       for (i = 0; i < G_N_ELEMENTS (blocked_plugins); i++) {
-               GstPlugin *plugin =
-                       gst_registry_find_plugin (registry,
-                                                 blocked_plugins[i]);
-               if (plugin)
-                       gst_registry_remove_plugin (registry, plugin);
-       }
+  GstRegistry *registry;
+  g_autolist(GstPluginFeature) hw_list = NULL;
+  GList *l;
+
+  registry = gst_registry_get ();
+  hw_list = gst_registry_feature_filter (registry, filter_hw_decoders, FALSE, NULL);
+  for (l = hw_list; l != NULL; l = l->next) {
+    g_debug ("Disabling feature %s",
+            gst_plugin_feature_get_name (l->data));
+    gst_registry_remove_feature (registry, l->data);
+  }
 }
 
 /*


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]