/* GStreamer Editing Services * * Copyright (C) <2013> Thibault Saunier * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "ges-validate.h" #ifdef HAVE_GST_VALIDATE #include #include #define MONITOR_ON_PIPELINE "validate-monitor" #define RUNNER_ON_PIPELINE "runner-monitor" static void _validate_report_added_cb (GstValidateRunner * runner, GstValidateReport * report, GstPipeline * pipeline) { if (report->level == GST_VALIDATE_REPORT_LEVEL_CRITICAL) { GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "ges-launch--validate-error"); } } gboolean ges_validate_activate (GstPipeline * pipeline, const gchar * scenario) { GstValidateRunner *runner = NULL; GstValidateMonitor *monitor = NULL; if (scenario) { gst_validate_init (); if (g_strcmp0 (scenario, "none")) { gchar *scenario_name = g_strconcat (scenario, "->gespipeline*", NULL); g_setenv ("GST_VALIDATE_SCENARIO", scenario_name, TRUE); g_free (scenario_name); } runner = gst_validate_runner_new (); g_signal_connect (runner, "report-added", G_CALLBACK (_validate_report_added_cb), pipeline); monitor = gst_validate_monitor_factory_create (GST_OBJECT_CAST (pipeline), runner, NULL); } g_object_set_data (G_OBJECT (pipeline), MONITOR_ON_PIPELINE, monitor); g_object_set_data (G_OBJECT (pipeline), RUNNER_ON_PIPELINE, runner); return TRUE; } gint ges_validate_clean (GstPipeline * pipeline) { gint res = 0; GstValidateMonitor *monitor = g_object_get_data (G_OBJECT (pipeline), MONITOR_ON_PIPELINE); GstValidateRunner *runner = g_object_get_data (G_OBJECT (pipeline), RUNNER_ON_PIPELINE); if (runner) res = gst_validate_runner_printf (runner); gst_object_unref (pipeline); if (runner) { gst_object_unref (runner); if (monitor) gst_object_unref (monitor); } return res; } #else gboolean ges_validate_activate (GstPipeline * pipeline, const gchar * scenario) { if (scenario) GST_WARNING ("Trying to run scenario %s, but gst-validate not supported", scenario); return TRUE; } gint ges_validate_clean (GstPipeline * pipeline) { gst_object_unref (pipeline); return 0; } #endif