[snappy] engine: Display verbose warning when missing plugins



commit 823ed153b056226916f10add1ee109fe853703f0
Author: Luis de Bethencourt <luis debethencourt com>
Date:   Thu Mar 14 13:48:34 2013 -0400

    engine: Display verbose warning when missing plugins

 src/gst_engine.c |   30 ++++++++++++++++++++++++++++--
 src/gst_engine.h |    1 +
 2 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/src/gst_engine.c b/src/gst_engine.c
index 560836e..1f78469 100644
--- a/src/gst_engine.c
+++ b/src/gst_engine.c
@@ -578,8 +578,11 @@ bus_call (GstBus * bus, GstMessage * msg, gpointer data)
 
       gst_message_parse_warning (msg, &err, &debug);
       if (err) {
-        g_print ("Warning: %s", err->message);
-        GST_DEBUG ("Warning: %s", err->message);
+        // If warning is missing plugins inform the user, if not display warning
+        if (!check_missing_plugins_error (engine, msg)) {
+          g_print ("Warning: %s", err->message);
+          GST_DEBUG ("Warning: %s", err->message);
+        }
 
         g_error_free (err);
 
@@ -654,6 +657,29 @@ change_state (GstEngine * engine, gchar * state)
   return ok;
 }
 
+gboolean
+check_missing_plugins_error (GstEngine * engine, GstMessage * msg)
+{
+  gboolean error_src_is_decoder, error_src_is_missing_plugins;
+  GError *err = NULL;
+
+  gst_message_parse_warning (msg, &err, NULL);
+
+  // Is the Error coming from uridecodebin?
+  error_src_is_decoder = g_str_has_prefix (gst_object_get_name (msg->src),
+      "uridecodebin");
+  // Is the error "Codec not found"? Then display verbose warning
+  if (error_src_is_decoder && err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND) {
+    g_print ("You are missing a GStreamer plugin needed to play this file.%s",
+             "\nCheck your GStreamer installation.\n");
+    GST_DEBUG("Warning: Codec not Found");
+    error_src_is_missing_plugins = TRUE;
+  } else {
+    error_src_is_missing_plugins = FALSE;
+  }
+
+  return error_src_is_missing_plugins;
+}
 
 /*               Cycle through streams           */
 gboolean
diff --git a/src/gst_engine.h b/src/gst_engine.h
index c3a6044..faa49c1 100644
--- a/src/gst_engine.h
+++ b/src/gst_engine.h
@@ -63,6 +63,7 @@ gboolean add_uri_unfinished (GstEngine * engine);
 gboolean at_the_eos (GstEngine * engine);
 gboolean bus_call (GstBus * bus, GstMessage * msg, gpointer data);
 gboolean change_state (GstEngine * engine, gchar * state);
+gboolean check_missing_plugins_error (GstEngine * engine, GstMessage * msg);
 gboolean cycle_streams (GstEngine * engine, guint streamid);
 gboolean engine_init (GstEngine * engine, GstElement * sink);
 void engine_load_uri (GstEngine * engine, gchar * uri);


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