[tracker: 1/3] tracker-extract: More helpful error when missing GStreamer plugins



commit cbc2794099fe173a9fb78e3bd2dfb169afb9629f
Author: Sam Thursfield <sam afuera me uk>
Date:   Fri Dec 26 22:39:59 2014 +0000

    tracker-extract: More helpful error when missing GStreamer plugins
    
    If extraction with GstDiscoverer fails due to lack of a plugin, we can
    display exactly what plugin was missing rather than just giving a
    generic error. This makes it a bit easier to fix the problem.

 src/tracker-extract/tracker-extract-gstreamer.c |   34 +++++++++++++++++++++-
 1 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index a15967b..7d52e0b 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -1418,6 +1418,28 @@ discoverer_shutdown (MetadataExtractor *extractor)
                g_object_unref (extractor->discoverer);
 }
 
+static gchar *
+get_discoverer_required_plugins_message (GstDiscovererInfo *info)
+{
+       GString *str;
+       gchar **plugins;
+       gchar *plugins_str;
+
+       plugins = (gchar **)
+               gst_discoverer_info_get_missing_elements_installer_details (info);
+
+       if (g_strv_length((gchar **)plugins) == 0) {
+               str = g_string_new ("No information available on which plugin is required.");
+       } else {
+               str = g_string_new("Required plugins: ");
+               plugins_str = g_strjoinv (", ", (gchar **)plugins);
+               g_string_append (str, plugins_str);
+               g_free (plugins_str);
+       }
+
+       return g_string_free (str, FALSE);
+}
+
 static gboolean
 discoverer_init_and_run (MetadataExtractor *extractor,
                          const gchar       *uri)
@@ -1426,6 +1448,7 @@ discoverer_init_and_run (MetadataExtractor *extractor,
        const GstTagList *discoverer_tags;
        GError *error = NULL;
        GList *l;
+       gchar *required_plugins_message;
 
        extractor->duration = -1;
        extractor->audio_channels = -1;
@@ -1467,8 +1490,15 @@ discoverer_init_and_run (MetadataExtractor *extractor,
        }
 
        if (error) {
-               g_warning ("Call to gst_discoverer_discover_uri() failed: %s",
-                          error->message);
+               if (gst_discoverer_info_get_result(info) == GST_DISCOVERER_MISSING_PLUGINS) {
+                       required_plugins_message = get_discoverer_required_plugins_message (info);
+                       g_warning ("Missing a GStreamer plugin for %s. %s", uri,
+                                  required_plugins_message);
+                       g_free (required_plugins_message);
+               } else {
+                       g_warning ("Call to gst_discoverer_discover_uri() failed: %s",
+                                  error->message);
+               }
                gst_discoverer_info_unref (info);
                g_error_free (error);
                return FALSE;


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