#include <gio/gio.h>
#include <string.h>
#include <errno.h>
+#include <math.h>
#include <gst/check/gsttestclock.h>
#include "gst-validate-internal.h"
}
#endif
+static void
+g_error_action (gpointer action, const gchar * format, ...)
+{
+ const gchar *filename = NULL;
+ gint lineno = -1;
+ gchar *f, *tmp;
+ va_list var_args;
+
+ if (action) {
+ if (GST_IS_STRUCTURE (action)) {
+ filename = gst_structure_get_string (action, "__filename__");
+ gst_structure_get_int (action, "__lineno__", &lineno);
+ } else {
+ filename = GST_VALIDATE_ACTION_FILENAME (action);
+ lineno = GST_VALIDATE_ACTION_LINENO (action);
+ }
+ }
+
+ f = filename ? g_strdup_printf ("\n> %s:%d\n> %d | %s\n> %*c|\n",
+ filename, lineno, lineno, format,
+ (gint) floor (log10 (abs ((lineno)))) + 1, ' ')
+ : g_strdup (format);
+
+ va_start (var_args, format);
+ tmp = gst_info_strdup_vprintf (f, var_args);
+ va_end (var_args);
+ g_free (f);
+
+ g_error ("%s", tmp);
+ g_free (tmp);
+}
+
static GstValidateInterceptionReturn
gst_validate_scenario_intercept_report (GstValidateReporter * reporter,
GstValidateReport * report)
{
if (!gst_validate_action_get_clocktime (scenario, action,
"playback-time", &action->playback_time)) {
- gchar *str = gst_structure_to_string (action->structure);
-
- g_error ("Could not parse playback-time on structure: %s", str);
- g_free (str);
+ g_error_action (action, "Could not parse playback-time in %" GST_PTR_FORMAT,
+ action->structure);
return FALSE;
}
priv->actions = g_list_remove_link (priv->actions, tmp);
if (!gst_validate_parse_next_action_playback_time (scenario)) {
- g_error ("Could not determine next action playback time!");
+ g_error_action (priv->actions ? priv->actions->data : NULL,
+ "Could not determine next action playback time!");
return G_SOURCE_REMOVE;
}
priv->actions = g_list_remove_link (priv->actions, tmp);
if (!gst_validate_parse_next_action_playback_time (scenario)) {
- g_error ("Could not determine next action playback time!");
+ g_error_action (priv->actions ? priv->actions->data : NULL,
+ "Could not determine next action playback time!");
return G_SOURCE_REMOVE;
}
repeat_expr =
g_strdup (gst_structure_get_string (action->structure, "repeat"));
if (!repeat_expr) {
- g_error ("Invalid value for 'repeat' in %s",
- gst_structure_to_string (action->structure));
-
+ g_error_action (action, "Invalid value for 'repeat'");
goto err;
}
gst_validate_utils_parse_expression (repeat_expr, _set_variable_func,
scenario, &error);
if (error) {
- g_error ("Invalid value for 'repeat' in %s: %s",
- gst_structure_to_string (action->structure), error);
-
+ g_error_action (action, "Invalid value for 'repeat'");
goto err;
}
g_free (repeat_expr);
continue;
}
- GST_ERROR_OBJECT (scenario, "We do not handle action types %s", type);
+ g_error_action (structure, "We do not handle action types %s", type);
goto failed;
}
if (action_type->parameters[i].mandatory &&
gst_structure_has_field (structure,
action_type->parameters[i].name) == FALSE) {
- GST_ERROR_OBJECT (scenario,
+ g_error_action (structure,
"Mandatory field '%s' not present in structure: %" GST_PTR_FORMAT,
action_type->parameters[i].name, structure);
goto failed;
GstValidateActionType *atype = _find_action_type (action_typename);
if (!atype) {
- g_error ("[CONFIG ERROR] Action type %s not found", action_typename);
+ g_error_action (plug_conf, "[CONFIG ERROR] Action type %s not found",
+ action_typename);
continue;
}
if (!(atype->flags & GST_VALIDATE_ACTION_TYPE_CONFIG) &&
!(_action_type_has_parameter (atype, "as-config"))) {
- g_error ("[CONFIG ERROR] Action '%s' is not a config action",
+ g_error_action (plug_conf,
+ "[CONFIG ERROR] Action '%s' is not a config action",
action_typename);
continue;