Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-devtools/-/merge_requests/248>
GST_VALIDATE_VERBOSITY_ALL = GST_VALIDATE_VERBOSITY_POSITION | GST_VALIDATE_VERBOSITY_MESSAGES | GST_VALIDATE_VERBOSITY_PROPS_CHANGES | GST_VALIDATE_VERBOSITY_NEW_ELEMENTS
} GstValidateVerbosityFlags;
-#endif /* __GST_VALIDATE_RUNNER_H__ */
+/**
+ * GstValidateStructureResolveVariablesFlags:
+ *
+ * Since: 1.20
+ */
+typedef enum {
+ GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_ALL = 0,
+ GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_LOCAL_ONLY = 1 << 0,
+ GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_NO_FAILURE = 1 << 1,
+ GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_NO_EXPRESSION = 1 << 1,
+} GstValidateStructureResolveVariablesFlags;
+
+#endif /* __GST_VALIDATE_ENUMS_H__ */
_update_well_known_vars (scenario);
strval =
gst_validate_replace_variables_in_string (action, scenario->priv->vars,
- tmpvalue);
+ tmpvalue, GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_ALL);
if (!strval)
return FALSE;
repeat_expr = gst_validate_replace_variables_in_string (action,
scenario->priv->vars, gst_structure_get_string (action->structure,
- "repeat"));
+ "repeat"), GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_ALL);
if (!repeat_expr) {
gst_validate_error_structure (action, "Invalid value for 'repeat'");
return FALSE;
GST_VALIDATE_ACTION_RANGE_NAME (action) : "repeat", G_TYPE_INT,
action->repeat, NULL);
gst_validate_structure_resolve_variables (action, action->structure,
- scenario->priv->vars);
+ scenario->priv->vars, GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_ALL);
for (i = 0; type->parameters[i].name; i++) {
if (type->parameters[i].types
&& g_str_has_suffix (type->parameters[i].types, "(GstClockTime)"))
gchar *
gst_validate_replace_variables_in_string (gpointer source,
- GstStructure * local_vars, const gchar * in_string)
+ GstStructure * local_vars, const gchar * in_string,
+ GstValidateStructureResolveVariablesFlags flags)
{
gint varname_len;
GMatchInfo *match_info = NULL;
if (local_vars)
var_value = gst_structure_get_value_as_string (local_vars, varname);
- if (!var_value)
+ if (!var_value
+ && !(flags & GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_LOCAL_ONLY))
var_value = gst_structure_get_value_as_string (global_vars, varname);
+ }
- if (!var_value) {
+ if (!var_value) {
+ if (!(flags & GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_NO_FAILURE)) {
gst_validate_error_structure (source,
"Trying to use undefined variable `%s`.\n"
" Available vars:\n"
" - locals%s\n"
" - globals%s\n",
varname, gst_structure_to_string (local_vars),
- gst_structure_to_string (global_vars));
-
- return NULL;
+ (flags & GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_LOCAL_ONLY) ?
+ ": unused" : gst_structure_to_string (global_vars));
}
+
+ return NULL;
}
tmp = g_strdup_printf ("\\$\\(%s\\)", varname);
{
gpointer source;
GstStructure *local_vars;
+ GstValidateStructureResolveVariablesFlags flags;
} ReplaceData;
static void
str =
gst_validate_replace_variables_in_string (data->source, data->local_vars,
- g_value_get_string (value));
+ g_value_get_string (value), data->flags);
if (str) {
g_value_set_string (value, str);
g_free (str);
}
- _resolve_expression (data->source, value);
+ if (!(data->flags & GST_VALIDATE_STRUCTURE_RESOLVE_VARIABLES_NO_EXPRESSION))
+ _resolve_expression (data->source, value);
return TRUE;
}
void
gst_validate_structure_resolve_variables (gpointer source,
- GstStructure * structure, GstStructure * local_variables)
+ GstStructure * structure, GstStructure * local_variables,
+ GstValidateStructureResolveVariablesFlags flags)
{
- ReplaceData d = { source ? source : structure, local_variables };
+ ReplaceData d = { source ? source : structure, local_variables, flags };
gst_structure_filter_and_map_in_place (structure,
(GstStructureFilterMapFunc) _structure_set_variables, &d);
GST_VALIDATE_API
gboolean gst_validate_element_matches_target (GstElement * element, GstStructure * s);
-gchar * gst_validate_replace_variables_in_string (gpointer incom, GstStructure * local_vars, const gchar * in_string);
+gchar * gst_validate_replace_variables_in_string (gpointer incom, GstStructure * local_vars, const gchar * in_string,
+ GstValidateStructureResolveVariablesFlags flags);
GST_VALIDATE_API
-void gst_validate_structure_resolve_variables (gpointer source, GstStructure *structure, GstStructure *local_variables);
+void gst_validate_structure_resolve_variables (gpointer source, GstStructure *structure, GstStructure *local_variables,
+ GstValidateStructureResolveVariablesFlags flags);
void gst_validate_structure_set_variables_from_struct_file(GstStructure* vars, const gchar* struct_file);
void gst_validate_set_globals(GstStructure* structure);
GST_VALIDATE_API
gst_structure_free (structure);
} else if (!loaded_globals
&& gst_structure_has_name (structure, "set-globals")) {
- gst_validate_structure_resolve_variables (NULL, structure, local_vars);
+ gst_validate_structure_resolve_variables (NULL, structure, local_vars, 0);
gst_validate_set_globals (structure);
gst_structure_free (structure);
} else {
- gst_validate_structure_resolve_variables (NULL, structure, local_vars);
+ gst_validate_structure_resolve_variables (NULL, structure, local_vars, 0);
all_configs = g_list_append (all_configs, structure);
}
}
gst_validate_scenario_check_and_set_needs_clock_sync (testfile_structs, &res);
gst_validate_set_test_file_globals (res, testfile, use_fakesinks);
- gst_validate_structure_resolve_variables (NULL, res, NULL);
+ gst_validate_structure_resolve_variables (NULL, res, NULL, 0);
tool = gst_structure_get_string (res, "tool");
if (!tool)
gst_structure_from_string ("vars, a=(string)1, b=(string)2", NULL);
GstStructure *s2 = gst_structure_from_string ("test, n=\"$(a)/$(b)\"", NULL);
- gst_validate_structure_resolve_variables (NULL, s2, s1);
+ gst_validate_structure_resolve_variables (NULL, s2, s1, 0);
fail_unless_equals_string (gst_structure_get_string (s2, "n"), "1/2");
gst_structure_free (s1);
gst_structure_free (s2);