Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / tools / gst-launch.c
index ade0efc..5a54f1c 100644 (file)
@@ -177,6 +177,7 @@ fault_setup (void)
 }
 #endif /* DISABLE_FAULT_HANDLER */
 
+#if 0
 typedef struct _GstIndexStats
 {
   gint id;
@@ -329,6 +330,27 @@ print_index_stats (GPtrArray * index_stats)
     }
   }
 }
+#endif
+
+/* Kids, use the functions from libgstpbutils in gst-plugins-base in your
+ * own code (we can't do that here because it would introduce a circular
+ * dependency) */
+static gboolean
+gst_is_missing_plugin_message (GstMessage * msg)
+{
+  if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ELEMENT
+      || gst_message_get_structure (msg) == NULL)
+    return FALSE;
+
+  return gst_structure_has_name (gst_message_get_structure (msg),
+      "missing-plugin");
+}
+
+static const gchar *
+gst_missing_plugin_message_get_description (GstMessage * msg)
+{
+  return gst_structure_get_string (gst_message_get_structure (msg), "name");
+}
 
 static void
 print_error_message (GstMessage * msg)
@@ -367,15 +389,11 @@ print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
       img = gst_value_get_buffer (gst_tag_list_get_value_index (list, tag, i));
       if (img) {
         gchar *caps_str;
-        GstCaps *caps;
 
-        caps = gst_buffer_caps (img);
-        caps_str = caps ? gst_caps_to_string (caps) : g_strdup ("unknown");
+        caps_str = g_strdup ("unknown");
         str = g_strdup_printf ("buffer of %" G_GSIZE_FORMAT " bytes, type: %s",
             gst_buffer_get_size (img), caps_str);
         g_free (caps_str);
-        if (caps)
-          gst_caps_unref (caps);
       } else {
         str = g_strdup ("NULL buffer");
       }
@@ -482,33 +500,6 @@ sigint_restore (void)
 
   sigaction (SIGINT, &action, NULL);
 }
-
-/* FIXME 0.11: remove SIGUSR handling (also from man page) */
-static void
-play_handler (int signum)
-{
-  switch (signum) {
-    case SIGUSR1:
-      PRINT ("Caught SIGUSR1 - Play request.\n");
-      gst_element_set_state (pipeline, GST_STATE_PLAYING);
-      break;
-    case SIGUSR2:
-      PRINT ("Caught SIGUSR2 - Stop request.\n");
-      gst_element_set_state (pipeline, GST_STATE_NULL);
-      break;
-  }
-}
-
-static void
-play_signal_setup (void)
-{
-  struct sigaction action;
-
-  memset (&action, 0, sizeof (action));
-  action.sa_handler = play_handler;
-  sigaction (SIGUSR1, &action, NULL);
-  sigaction (SIGUSR2, &action, NULL);
-}
 #endif /* DISABLE_FAULT_HANDLER */
 
 /* returns ELR_ERROR if there was an error
@@ -751,6 +742,16 @@ event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
           res = ELR_INTERRUPT;
           goto exit;
         }
+        break;
+      }
+      case GST_MESSAGE_ELEMENT:{
+        if (gst_is_missing_plugin_message (message)) {
+          const gchar *desc;
+
+          desc = gst_missing_plugin_message_get_description (message);
+          PRINT (_("Missing element: %s\n"), desc ? desc : "(no description)");
+        }
+        break;
       }
       default:
         /* just be quiet by default */
@@ -821,10 +822,11 @@ main (int argc, char *argv[])
   /* options */
   gboolean verbose = FALSE;
   gboolean no_fault = FALSE;
-  gboolean no_sigusr_handler = FALSE;
   gboolean trace = FALSE;
   gboolean eos_on_shutdown = FALSE;
+#if 0
   gboolean check_index = FALSE;
+#endif
   gchar *savefile = NULL;
   gchar *exclude_args = NULL;
 #ifndef GST_DISABLE_OPTION_PARSING
@@ -841,22 +843,24 @@ main (int argc, char *argv[])
         N_("Do not output status information of TYPE"), N_("TYPE1,TYPE2,...")},
     {"no-fault", 'f', 0, G_OPTION_ARG_NONE, &no_fault,
         N_("Do not install a fault handler"), NULL},
-    {"no-sigusr-handler", '\0', 0, G_OPTION_ARG_NONE, &no_sigusr_handler,
-        N_("Do not install signal handlers for SIGUSR1 and SIGUSR2"), NULL},
     {"trace", 'T', 0, G_OPTION_ARG_NONE, &trace,
         N_("Print alloc trace (if enabled at compile time)"), NULL},
     {"eos-on-shutdown", 'e', 0, G_OPTION_ARG_NONE, &eos_on_shutdown,
         N_("Force EOS on sources before shutting the pipeline down"), NULL},
+#if 0
     {"index", 'i', 0, G_OPTION_ARG_NONE, &check_index,
         N_("Gather and print index statistics"), NULL},
+#endif
     GST_TOOLS_GOPTION_VERSION,
     {NULL}
   };
   GOptionContext *ctx;
   GError *err = NULL;
 #endif
+#if 0
   GstIndex *index;
   GPtrArray *index_stats = NULL;
+#endif
   gchar **argvn;
   GError *error = NULL;
   gint res = 0;
@@ -869,7 +873,9 @@ main (int argc, char *argv[])
   textdomain (GETTEXT_PACKAGE);
 #endif
 
+#if !GLIB_CHECK_VERSION (2, 31, 0)
   g_thread_init (NULL);
+#endif
 
   gst_tools_set_prgname ("gst-launch");
 
@@ -896,9 +902,6 @@ main (int argc, char *argv[])
     fault_setup ();
 
   sigint_setup ();
-
-  if (!no_sigusr_handler)
-    play_signal_setup ();
 #endif
 
   if (trace) {
@@ -958,7 +961,7 @@ main (int argc, char *argv[])
       gst_bin_add (GST_BIN (real_pipeline), pipeline);
       pipeline = real_pipeline;
     }
-
+#if 0
     if (check_index) {
       /* gst_index_new() creates a null-index, it does not store anything, but
        * the entry-added signal works and this is what we use to build the
@@ -973,6 +976,7 @@ main (int argc, char *argv[])
         gst_element_set_index (pipeline, index);
       }
     }
+#endif
 
     bus = gst_element_get_bus (pipeline);
     gst_bus_set_sync_handler (bus, bus_sync_handler, (gpointer) pipeline);
@@ -1066,10 +1070,12 @@ main (int argc, char *argv[])
     gst_element_set_state (pipeline, GST_STATE_READY);
     gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
 
+#if 0
     if (check_index) {
       print_index_stats (index_stats);
       g_ptr_array_free (index_stats, TRUE);
     }
+#endif
 
   end:
     PRINT (_("Setting pipeline to NULL ...\n"));