#include <gst/gst.h>
#include <string.h>
+#include <stdlib.h>
#include <gst/validate/validate.h>
#define __USE_GNU
static GstValidateRunner *runner = NULL;
+static void
+exit_report_printer (void)
+{
+ if (runner)
+ gst_validate_runner_printf (runner);
+}
+
/*
* Functions that wrap object creation so gst-validate can be used
* to monitor 'standard' applications
if (runner == NULL) {
gst_validate_init ();
runner = gst_validate_runner_new ();
+ atexit (exit_report_printer);
}
/* the reference to the monitor is lost */
* after pipeline ends? */
return runner->reports;
}
+
+int
+gst_validate_runner_printf (GstValidateRunner * runner)
+{
+ GSList *tmp;
+ guint count = 0;
+ int ret = 0;
+
+ for (tmp = gst_validate_runner_get_reports (runner); tmp; tmp = tmp->next) {
+ GstValidateReport *report = tmp->data;
+
+ gst_validate_report_printf (report);
+ if (ret == 0 && report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) {
+ g_printerr ("Got critical error %s, setting return value to -1\n",
+ ((GstValidateReport *) (tmp->data))->message);
+ ret = -1;
+ }
+ count++;
+ }
+ g_print ("Pipeline finished, issues found: %u\n", count);
+ return ret;
+}
guint gst_validate_runner_get_reports_count (GstValidateRunner * runner);
GSList * gst_validate_runner_get_reports (GstValidateRunner * runner);
+int gst_validate_runner_printf (GstValidateRunner * runner);
+
G_END_DECLS
#endif /* __GST_VALIDATE_RUNNER_H__ */
int
main (int argc, gchar ** argv)
{
- GSList *tmp;
GError *err = NULL;
const gchar *scenario = NULL;
gboolean list_scenarios = FALSE;
#ifdef G_OS_UNIX
guint signal_watch_id;
#endif
- guint count = 0;
+ int rep_err;
GOptionEntry options[] = {
{"set-scenario", '\0', 0, G_OPTION_ARG_STRING, &scenario,
g_print ("Pipeline started\n");
g_main_loop_run (mainloop);
- tmp = gst_validate_runner_get_reports (runner);
- tmp = g_slist_reverse (tmp);
-
- g_print ("Pipeline finished\n");
- count = g_slist_length (tmp);
- if (count) {
- g_print ("\nFound %u issues\n", count);
-
- for (; tmp; tmp = tmp->next) {
- GstValidateReport *report = tmp->data;
-
- gst_validate_report_printf (report);
- if (ret == 0 && report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL)
- ret = -1;
- }
- }
+ rep_err = gst_validate_runner_printf (runner);
+ if (ret == 0)
+ ret = rep_err;
exit:
gst_element_set_state (pipeline, GST_STATE_NULL);