From 5cb60060dc7556e1938ca68582df81452d38e4de Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Fri, 10 Oct 2014 03:55:37 +0200 Subject: [PATCH] validate-runner / monitor: Let the user single out pads. That's some pretty specific code but it should be helpful. The following syntax can be used : element-name::pad-name. + Free return of gst_object_get_name. --- validate/gst/validate/gst-validate-monitor.c | 27 ++++++++++++++++++++++++++- validate/gst/validate/gst-validate-runner.c | 23 +++++++++++++++++++++-- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/validate/gst/validate/gst-validate-monitor.c b/validate/gst/validate/gst-validate-monitor.c index 9c9bf27..f296f53 100644 --- a/validate/gst/validate/gst-validate-monitor.c +++ b/validate/gst/validate/gst-validate-monitor.c @@ -188,23 +188,48 @@ gst_validate_monitor_do_setup (GstValidateMonitor * monitor) return TRUE; } +static GstValidateReportingLevel +_get_report_level_for_pad (GstValidateRunner *runner, GstObject *pad) +{ + GstObject *parent; + gchar *name; + GstValidateReportingLevel level = GST_VALIDATE_REPORTING_LEVEL_UNKNOWN; + + parent = gst_object_get_parent (pad); + + name = g_strdup_printf ("%s__%s", GST_DEBUG_PAD_NAME (pad)); + level = gst_validate_runner_get_reporting_level_for_name (runner, name); + + g_free (name); + gst_object_unref (parent); + return level; +} + static void _determine_reporting_level (GstValidateMonitor *monitor) { GstValidateRunner *runner; GstObject *object, *parent; - const gchar *object_name; + gchar *object_name; GstValidateReportingLevel level = GST_VALIDATE_REPORTING_LEVEL_UNKNOWN; object = gst_object_ref(monitor->target); runner = gst_validate_reporter_get_runner (GST_VALIDATE_REPORTER (monitor)); do { + /* Let's allow for singling out pads */ + if (GST_IS_PAD (object)) { + level = _get_report_level_for_pad (runner, object); + if (level != GST_VALIDATE_REPORTING_LEVEL_UNKNOWN) + break; + } + object_name = gst_object_get_name (object); level = gst_validate_runner_get_reporting_level_for_name (runner, object_name); parent = gst_object_get_parent (object); gst_object_unref (object); object = parent; + g_free (object_name); } while (object && level == GST_VALIDATE_REPORTING_LEVEL_UNKNOWN); if (object) diff --git a/validate/gst/validate/gst-validate-runner.c b/validate/gst/validate/gst-validate-runner.c index b77f19c..50ad0d9 100644 --- a/validate/gst/validate/gst-validate-runner.c +++ b/validate/gst/validate/gst-validate-runner.c @@ -154,8 +154,26 @@ _set_reporting_level_for_name (GstValidateRunner * runner, pattern_level->pattern = pattern_spec; pattern_level->level = level; - runner->priv->report_pattern_levels = - g_list_append (runner->priv->report_pattern_levels, pattern_level); + /* Allow the user to single out a pad with the "element-name__pad-name" syntax + */ + if (g_strrstr (pattern, "__")) + runner->priv->report_pattern_levels = + g_list_prepend (runner->priv->report_pattern_levels, pattern_level); + else + runner->priv->report_pattern_levels = + g_list_append (runner->priv->report_pattern_levels, pattern_level); +} + +static void +_replace_double_colons (gchar *word) +{ + while (word) { + word = strstr (word, "::"); + if (word) { + word[0] = '_'; + word[1] = '_'; + } + } } static void @@ -171,6 +189,7 @@ _set_report_levels_from_string (GstValidateRunner * self, const gchar * list) split = g_strsplit (list, ",", 0); for (walk = split; *walk; walk++) { + _replace_double_colons (*walk); if (strchr (*walk, ':')) { gchar **values = g_strsplit (*walk, ":", 2); -- 2.7.4