2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
4 * 2004 Thomas Vander Stichele <thomas@apestaart.org>
6 * gst-launch.c: tool to launch GStreamer pipelines from the command line
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
28 /* FIXME: hack alert */
30 #define DISABLE_FAULT_HANDLER
39 #ifndef DISABLE_FAULT_HANDLER
42 #include <locale.h> /* for LC_ALL */
45 /* FIXME: This is just a temporary hack. We should have a better
46 * check for siginfo handling. */
51 extern volatile gboolean glib_on_error_halt;
53 #ifndef DISABLE_FAULT_HANDLER
54 static void fault_restore (void);
55 static void fault_spin (void);
56 static void sigint_restore (void);
57 static gboolean caught_intr = FALSE;
60 /* event_loop return codes */
61 typedef enum _EventLoopResult
68 static GstElement *pipeline;
69 static EventLoopResult caught_error = ELR_NO_ERROR;
70 static gboolean quiet = FALSE;
71 static gboolean tags = FALSE;
72 static gboolean messages = FALSE;
73 static gboolean is_live = FALSE;
74 static gboolean waiting_eos = FALSE;
76 /* convenience macro so we don't have to litter the code with if(!quiet) */
77 #define PRINT if(!quiet)g_print
79 #ifndef GST_DISABLE_LOADSAVE
81 xmllaunch_parse_cmdline (const gchar ** argv)
83 GstElement *pipeline = NULL, *e;
87 gchar *element, *property, *value;
91 if (!(arg = argv[0])) {
93 ("Usage: gst-xmllaunch <file.xml> [ element.property=value ... ]\n"));
98 /* FIXME guchar from gstxml.c */
99 err = gst_xml_parse_file (xml, (guchar *) arg, NULL);
102 g_printerr (_("ERROR: parse of xml file '%s' failed.\n"), arg);
106 l = gst_xml_get_topelements (xml);
108 g_printerr (_("ERROR: no toplevel pipeline element in file '%s'.\n"), arg);
114 _("WARNING: only one toplevel element is supported at this time.\n"));
117 pipeline = GST_ELEMENT (l->data);
119 while ((arg = argv[++i])) {
120 element = g_strdup (arg);
121 property = strchr (element, '.');
122 value = strchr (element, '=');
124 if (!(element < property && property < value)) {
125 g_printerr (_("ERROR: could not parse command line argument %d: %s.\n"),
134 e = gst_bin_get_by_name (GST_BIN (pipeline), element);
136 g_printerr (_("WARNING: element named '%s' not found.\n"), element);
138 gst_util_set_object_arg (G_OBJECT (e), property, value);
146 gst_object_ref (pipeline);
147 gst_object_unref (xml);
152 #ifndef DISABLE_FAULT_HANDLER
155 fault_handler_sighandler (int signum)
159 /* printf is used instead of g_print(), since it's less likely to
163 printf ("Caught SIGSEGV\n");
166 printf ("Caught SIGQUIT\n");
169 printf ("signo: %d\n", signum);
176 #else /* USE_SIGINFO */
179 fault_handler_sigaction (int signum, siginfo_t * si, void *misc)
183 /* printf is used instead of g_print(), since it's less likely to
185 switch (si->si_signo) {
187 printf ("Caught SIGSEGV accessing address %p\n", si->si_addr);
190 printf ("Caught SIGQUIT\n");
193 printf ("signo: %d\n", si->si_signo);
194 printf ("errno: %d\n", si->si_errno);
195 printf ("code: %d\n", si->si_code);
201 #endif /* USE_SIGINFO */
208 glib_on_error_halt = FALSE;
209 g_on_error_stack_trace ("gst-launch");
213 /* FIXME how do we know if we were run by libtool? */
214 printf ("Spinning. Please run 'gdb gst-launch %d' to continue debugging, "
215 "Ctrl-C to quit, or Ctrl-\\ to dump core.\n", (gint) getpid ());
223 struct sigaction action;
225 memset (&action, 0, sizeof (action));
226 action.sa_handler = SIG_DFL;
228 sigaction (SIGSEGV, &action, NULL);
229 sigaction (SIGQUIT, &action, NULL);
235 struct sigaction action;
237 memset (&action, 0, sizeof (action));
239 action.sa_sigaction = fault_handler_sigaction;
240 action.sa_flags = SA_SIGINFO;
242 action.sa_handler = fault_handler_sighandler;
245 sigaction (SIGSEGV, &action, NULL);
246 sigaction (SIGQUIT, &action, NULL);
248 #endif /* DISABLE_FAULT_HANDLER */
251 print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
255 count = gst_tag_list_get_tag_size (list, tag);
257 for (i = 0; i < count; i++) {
260 if (gst_tag_get_type (tag) == G_TYPE_STRING) {
261 if (!gst_tag_list_get_string_index (list, tag, i, &str))
262 g_assert_not_reached ();
263 } else if (gst_tag_get_type (tag) == GST_TYPE_BUFFER) {
266 img = gst_value_get_buffer (gst_tag_list_get_value_index (list, tag, i));
270 caps_str = GST_BUFFER_CAPS (img) ?
271 gst_caps_to_string (GST_BUFFER_CAPS (img)) : g_strdup ("unknown");
272 str = g_strdup_printf ("buffer of %u bytes, type: %s",
273 GST_BUFFER_SIZE (img), caps_str);
276 str = g_strdup ("NULL buffer");
280 g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
284 g_print ("%16s: %s\n", gst_tag_get_nick (tag), str);
286 g_print ("%16s: %s\n", "", str);
293 #ifndef DISABLE_FAULT_HANDLER
294 /* we only use sighandler here because the registers are not important */
296 sigint_handler_sighandler (int signum)
298 g_print ("Caught interrupt -- ");
300 /* If we were waiting for an EOS, we still want to catch
301 * the next signal to shutdown properly (and the following one
302 * will quit the program). */
308 /* we set a flag that is checked by the mainloop, we cannot do much in the
309 * interrupt handler (no mutex or other blocking stuff) */
313 /* is called every 250 milliseconds (4 times a second), the interrupt handler
314 * will set a flag for us. We react to this by posting a message. */
316 check_intr (GstElement * pipeline)
322 g_print ("handling interrupt.\n");
324 /* post an application specific message */
325 gst_element_post_message (GST_ELEMENT (pipeline),
326 gst_message_new_application (GST_OBJECT (pipeline),
327 gst_structure_new ("GstLaunchInterrupt",
328 "message", G_TYPE_STRING, "Pipeline interrupted", NULL)));
330 /* remove timeout handler */
338 struct sigaction action;
340 memset (&action, 0, sizeof (action));
341 action.sa_handler = sigint_handler_sighandler;
343 sigaction (SIGINT, &action, NULL);
347 sigint_restore (void)
349 struct sigaction action;
351 memset (&action, 0, sizeof (action));
352 action.sa_handler = SIG_DFL;
354 sigaction (SIGINT, &action, NULL);
358 play_handler (int signum)
362 g_print ("Caught SIGUSR1 - Play request.\n");
363 gst_element_set_state (pipeline, GST_STATE_PLAYING);
366 g_print ("Caught SIGUSR2 - Stop request.\n");
367 gst_element_set_state (pipeline, GST_STATE_NULL);
373 play_signal_setup (void)
375 struct sigaction action;
377 memset (&action, 0, sizeof (action));
378 action.sa_handler = play_handler;
379 sigaction (SIGUSR1, &action, NULL);
380 sigaction (SIGUSR2, &action, NULL);
382 #endif /* DISABLE_FAULT_HANDLER */
384 /* returns ELR_ERROR if there was an error
385 * or ELR_INTERRUPT if we caught a keyboard interrupt
386 * or ELR_NO_ERROR otherwise. */
387 static EventLoopResult
388 event_loop (GstElement * pipeline, gboolean blocking, GstState target_state)
390 #ifndef DISABLE_FAULT_HANDLER
394 GstMessage *message = NULL;
395 EventLoopResult res = ELR_NO_ERROR;
396 gboolean buffering = FALSE;
398 bus = gst_element_get_bus (GST_ELEMENT (pipeline));
400 #ifndef DISABLE_FAULT_HANDLER
401 timeout_id = g_timeout_add (250, (GSourceFunc) check_intr, pipeline);
405 message = gst_bus_poll (bus, GST_MESSAGE_ANY, blocking ? -1 : 0);
407 /* if the poll timed out, only when !blocking */
411 /* check if we need to dump messages to the console */
414 const GstStructure *s;
417 seqnum = gst_message_get_seqnum (message);
419 s = gst_message_get_structure (message);
421 src_obj = GST_MESSAGE_SRC (message);
423 if (GST_IS_ELEMENT (src_obj)) {
424 PRINT (_("Got message #%u from element \"%s\" (%s): "),
425 (guint) seqnum, GST_ELEMENT_NAME (src_obj),
426 GST_MESSAGE_TYPE_NAME (message));
427 } else if (GST_IS_PAD (src_obj)) {
428 PRINT (_("Got message #%u from pad \"%s:%s\" (%s): "),
429 (guint) seqnum, GST_DEBUG_PAD_NAME (src_obj),
430 GST_MESSAGE_TYPE_NAME (message));
431 } else if (GST_IS_OBJECT (src_obj)) {
432 PRINT (_("Got message #%u from object \"%s\" (%s): "),
433 (guint) seqnum, GST_OBJECT_NAME (src_obj),
434 GST_MESSAGE_TYPE_NAME (message));
436 PRINT (_("Got message #%u (%s): "), (guint) seqnum,
437 GST_MESSAGE_TYPE_NAME (message));
443 sstr = gst_structure_to_string (s);
444 PRINT ("%s\n", sstr);
447 PRINT ("no message details\n");
451 switch (GST_MESSAGE_TYPE (message)) {
452 case GST_MESSAGE_NEW_CLOCK:
456 gst_message_parse_new_clock (message, &clock);
458 PRINT ("New clock: %s\n", (clock ? GST_OBJECT_NAME (clock) : "NULL"));
461 case GST_MESSAGE_CLOCK_LOST:
463 /* disabled for now as it caused problems with rtspsrc. We need to fix
464 * rtspsrc first, then release -good before we can reenable this again
466 PRINT ("Clock lost, selecting a new one\n");
467 gst_element_set_state (pipeline, GST_STATE_PAUSED);
468 gst_element_set_state (pipeline, GST_STATE_PLAYING);
471 case GST_MESSAGE_EOS:{
473 PRINT (_("Got EOS from element \"%s\".\n"),
474 GST_MESSAGE_SRC_NAME (message));
477 case GST_MESSAGE_TAG:
481 if (GST_IS_ELEMENT (GST_MESSAGE_SRC (message))) {
482 PRINT (_("FOUND TAG : found by element \"%s\".\n"),
483 GST_MESSAGE_SRC_NAME (message));
484 } else if (GST_IS_PAD (GST_MESSAGE_SRC (message))) {
485 PRINT (_("FOUND TAG : found by pad \"%s:%s\".\n"),
486 GST_DEBUG_PAD_NAME (GST_MESSAGE_SRC (message)));
487 } else if (GST_IS_OBJECT (GST_MESSAGE_SRC (message))) {
488 PRINT (_("FOUND TAG : found by object \"%s\".\n"),
489 GST_MESSAGE_SRC_NAME (message));
491 PRINT (_("FOUND TAG\n"));
494 gst_message_parse_tag (message, &tags);
495 gst_tag_list_foreach (tags, print_tag, NULL);
496 gst_tag_list_free (tags);
499 case GST_MESSAGE_INFO:{
502 gchar *name = gst_object_get_path_string (GST_MESSAGE_SRC (message));
504 gst_message_parse_info (message, &gerror, &debug);
506 PRINT (_("INFO:\n%s\n"), debug);
508 g_error_free (gerror);
513 case GST_MESSAGE_WARNING:{
516 gchar *name = gst_object_get_path_string (GST_MESSAGE_SRC (message));
518 /* dump graph on warning */
519 GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
520 GST_DEBUG_GRAPH_SHOW_ALL, "gst-launch.warning");
522 gst_message_parse_warning (message, &gerror, &debug);
523 PRINT (_("WARNING: from element %s: %s\n"), name, gerror->message);
525 PRINT (_("Additional debug info:\n%s\n"), debug);
527 g_error_free (gerror);
532 case GST_MESSAGE_ERROR:{
536 /* dump graph on error */
537 GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
538 GST_DEBUG_GRAPH_SHOW_ALL, "gst-launch.error");
540 gst_message_parse_error (message, &gerror, &debug);
541 gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
542 g_error_free (gerror);
544 /* we have an error */
548 case GST_MESSAGE_STATE_CHANGED:{
549 GstState old, new, pending;
551 gst_message_parse_state_changed (message, &old, &new, &pending);
553 /* we only care about pipeline state change messages */
554 if (GST_MESSAGE_SRC (message) != GST_OBJECT_CAST (pipeline))
557 /* dump graph for pipeline state changes */
559 gchar *dump_name = g_strdup_printf ("gst-launch.%s_%s",
560 gst_element_state_get_name (old),
561 gst_element_state_get_name (new));
562 GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
563 GST_DEBUG_GRAPH_SHOW_ALL, dump_name);
567 /* ignore when we are buffering since then we mess with the states
570 PRINT (_("Prerolled, waiting for buffering to finish...\n"));
574 /* if we reached the final target state, exit */
575 if (target_state == GST_STATE_PAUSED && new == target_state)
578 /* else not an interesting message */
581 case GST_MESSAGE_BUFFERING:{
584 gst_message_parse_buffering (message, &percent);
585 PRINT ("%s %d%% \r", _("buffering..."), percent);
587 /* no state management needed for live pipelines */
591 if (percent == 100) {
592 /* a 100% message means buffering is done */
594 /* if the desired state is playing, go back */
595 if (target_state == GST_STATE_PLAYING) {
596 PRINT (_("Done buffering, setting pipeline to PLAYING ...\n"));
597 gst_element_set_state (pipeline, GST_STATE_PLAYING);
602 if (buffering == FALSE && target_state == GST_STATE_PLAYING) {
603 /* we were not buffering but PLAYING, PAUSE the pipeline. */
604 PRINT (_("Buffering, setting pipeline to PAUSED ...\n"));
605 gst_element_set_state (pipeline, GST_STATE_PAUSED);
611 case GST_MESSAGE_LATENCY:
613 PRINT (_("Redistribute latency...\n"));
614 gst_bin_recalculate_latency (GST_BIN (pipeline));
617 case GST_MESSAGE_REQUEST_STATE:
620 gchar *name = gst_object_get_path_string (GST_MESSAGE_SRC (message));
622 gst_message_parse_request_state (message, &state);
624 PRINT (_("Setting state to %s as requested by %s...\n"),
625 gst_element_state_get_name (state), name);
627 gst_element_set_state (pipeline, state);
632 case GST_MESSAGE_APPLICATION:{
633 const GstStructure *s;
635 s = gst_message_get_structure (message);
637 if (gst_structure_has_name (s, "GstLaunchInterrupt")) {
638 /* this application message is posted when we caught an interrupt and
639 * we need to stop the pipeline. */
640 PRINT (_("Interrupt: Stopping pipeline ...\n"));
646 /* just be quiet by default */
650 gst_message_unref (message);
652 g_assert_not_reached ();
657 gst_message_unref (message);
658 gst_object_unref (bus);
659 #ifndef DISABLE_FAULT_HANDLER
660 g_source_remove (timeout_id);
667 main (int argc, char *argv[])
670 gboolean verbose = FALSE;
671 gboolean no_fault = FALSE;
672 gboolean no_play = FALSE;
673 gboolean trace = FALSE;
674 gboolean eos_on_shutdown = FALSE;
675 gchar *savefile = NULL;
676 gchar *exclude_args = NULL;
677 #ifndef GST_DISABLE_OPTION_PARSING
678 GOptionEntry options[] = {
679 {"tags", 't', 0, G_OPTION_ARG_NONE, &tags,
680 N_("Output tags (also known as metadata)"), NULL},
681 {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
682 N_("Output status information and property notifications"), NULL},
683 {"quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet,
684 N_("Do not print any progress information"), NULL},
685 {"messages", 'm', 0, G_OPTION_ARG_NONE, &messages,
686 N_("Output messages"), NULL},
687 {"exclude", 'X', 0, G_OPTION_ARG_NONE, &exclude_args,
688 N_("Do not output status information of TYPE"), N_("TYPE1,TYPE2,...")},
689 #ifndef GST_DISABLE_LOADSAVE
690 {"output", 'o', 0, G_OPTION_ARG_STRING, &savefile,
691 N_("Save xml representation of pipeline to FILE and exit"), N_("FILE")},
693 {"no-fault", 'f', 0, G_OPTION_ARG_NONE, &no_fault,
694 N_("Do not install a fault handler"), NULL},
695 {"no-play", 'p', 0, G_OPTION_ARG_NONE, &no_play,
696 N_("Do not install a play handler"), NULL},
697 {"trace", 'T', 0, G_OPTION_ARG_NONE, &trace,
698 N_("Print alloc trace (if enabled at compile time)"), NULL},
699 {"eos-on-shutdown", 'e', 0, G_OPTION_ARG_NONE, &eos_on_shutdown,
700 N_("Force EOS on sources before shutting the pipeline down"), NULL},
701 GST_TOOLS_GOPTION_VERSION,
708 GError *error = NULL;
711 free (malloc (8)); /* -lefence */
714 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
715 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
716 textdomain (GETTEXT_PACKAGE);
719 g_thread_init (NULL);
721 gst_tools_set_prgname ("gst-launch");
723 #ifndef GST_DISABLE_OPTION_PARSING
724 ctx = g_option_context_new ("PIPELINE-DESCRIPTION");
725 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
726 g_option_context_add_group (ctx, gst_init_get_option_group ());
727 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
729 g_printerr ("Error initializing: %s\n", GST_STR_NULL (err->message));
731 g_printerr ("Error initializing: Unknown error!\n");
734 g_option_context_free (ctx);
736 gst_init (&argc, &argv);
739 gst_tools_print_version ("gst-launch");
741 #ifndef DISABLE_FAULT_HANDLER
748 play_signal_setup ();
752 if (!gst_alloc_trace_available ()) {
753 g_warning ("Trace not available (recompile with trace enabled).");
755 gst_alloc_trace_set_flags_all (GST_ALLOC_TRACE_LIVE |
756 GST_ALLOC_TRACE_MEM_LIVE);
757 gst_alloc_trace_print_live ();
760 /* make a null-terminated version of argv */
761 argvn = g_new0 (char *, argc);
762 memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
763 #ifndef GST_DISABLE_LOADSAVE
764 if (strstr (argv[0], "gst-xmllaunch")) {
765 pipeline = xmllaunch_parse_cmdline ((const gchar **) argvn);
770 (GstElement *) gst_parse_launchv ((const gchar **) argvn, &error);
776 g_printerr (_("ERROR: pipeline could not be constructed: %s.\n"),
777 GST_STR_NULL (error->message));
778 g_error_free (error);
780 g_printerr (_("ERROR: pipeline could not be constructed.\n"));
784 g_printerr (_("WARNING: erroneous pipeline: %s\n"),
785 GST_STR_NULL (error->message));
786 g_error_free (error);
791 gchar **exclude_list =
792 exclude_args ? g_strsplit (exclude_args, ",", 0) : NULL;
793 g_signal_connect (pipeline, "deep-notify",
794 G_CALLBACK (gst_object_default_deep_notify), exclude_list);
796 #ifndef GST_DISABLE_LOADSAVE
798 gst_xml_write_file (GST_ELEMENT (pipeline), fopen (savefile, "w"));
803 GstState state, pending;
804 GstStateChangeReturn ret;
806 /* If the top-level object is not a pipeline, place it in a pipeline. */
807 if (!GST_IS_PIPELINE (pipeline)) {
808 GstElement *real_pipeline = gst_element_factory_make ("pipeline", NULL);
810 if (real_pipeline == NULL) {
811 g_printerr (_("ERROR: the 'pipeline' element wasn't found.\n"));
814 gst_bin_add (GST_BIN (real_pipeline), pipeline);
815 pipeline = real_pipeline;
817 PRINT (_("Setting pipeline to PAUSED ...\n"));
818 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
821 case GST_STATE_CHANGE_FAILURE:
822 g_printerr (_("ERROR: Pipeline doesn't want to pause.\n"));
824 event_loop (pipeline, FALSE, GST_STATE_VOID_PENDING);
826 case GST_STATE_CHANGE_NO_PREROLL:
827 PRINT (_("Pipeline is live and does not need PREROLL ...\n"));
830 case GST_STATE_CHANGE_ASYNC:
831 PRINT (_("Pipeline is PREROLLING ...\n"));
832 caught_error = event_loop (pipeline, TRUE, GST_STATE_PAUSED);
834 g_printerr (_("ERROR: pipeline doesn't want to preroll.\n"));
837 state = GST_STATE_PAUSED;
839 case GST_STATE_CHANGE_SUCCESS:
840 PRINT (_("Pipeline is PREROLLED ...\n"));
844 caught_error = event_loop (pipeline, FALSE, GST_STATE_PLAYING);
847 g_printerr (_("ERROR: pipeline doesn't want to preroll.\n"));
849 GstClockTime tfthen, tfnow;
850 GstClockTimeDiff diff;
852 PRINT (_("Setting pipeline to PLAYING ...\n"));
854 if (gst_element_set_state (pipeline,
855 GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
859 g_printerr (_("ERROR: pipeline doesn't want to play.\n"));
860 bus = gst_element_get_bus (pipeline);
861 if ((err_msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0))) {
865 gst_message_parse_error (err_msg, &gerror, &debug);
866 gst_object_default_error (GST_MESSAGE_SRC (err_msg), gerror, debug);
867 gst_message_unref (err_msg);
868 g_error_free (gerror);
871 gst_object_unref (bus);
876 tfthen = gst_util_get_timestamp ();
877 caught_error = event_loop (pipeline, TRUE, GST_STATE_PLAYING);
878 if (eos_on_shutdown && caught_error == ELR_INTERRUPT) {
879 PRINT (_("EOS on shutdown enabled -- Forcing EOS on the pipeline\n"));
881 gst_element_send_event (pipeline, gst_event_new_eos ());
882 PRINT (_("Waiting for EOS...\n"));
883 caught_error = event_loop (pipeline, TRUE, GST_STATE_PLAYING);
885 if (caught_error == ELR_NO_ERROR) {
887 PRINT (_("EOS received - stopping pipeline...\n"));
888 } else if (caught_error == ELR_ERROR) {
889 PRINT (_("An error happened while waiting for EOS\n"));
892 tfnow = gst_util_get_timestamp ();
894 diff = GST_CLOCK_DIFF (tfthen, tfnow);
896 PRINT (_("Execution ended after %" G_GUINT64_FORMAT " ns.\n"), diff);
899 PRINT (_("Setting pipeline to PAUSED ...\n"));
900 gst_element_set_state (pipeline, GST_STATE_PAUSED);
901 if (caught_error == ELR_NO_ERROR)
902 gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
904 /* iterate mainloop to process pending stuff */
905 while (g_main_context_iteration (NULL, FALSE));
907 PRINT (_("Setting pipeline to READY ...\n"));
908 gst_element_set_state (pipeline, GST_STATE_READY);
909 gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
912 PRINT (_("Setting pipeline to NULL ...\n"));
913 gst_element_set_state (pipeline, GST_STATE_NULL);
914 gst_element_get_state (pipeline, &state, &pending, GST_CLOCK_TIME_NONE);
917 PRINT (_("Freeing pipeline ...\n"));
918 gst_object_unref (pipeline);
922 gst_alloc_trace_print_live ();