mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 23:48:53 +00:00
validate: Cleanup flags/enum_from_string
This commit is contained in:
parent
f9190236af
commit
d0ee26e950
2 changed files with 19 additions and 23 deletions
|
@ -1123,8 +1123,7 @@ execute_switch_track_pb (GstValidateScenario * scenario,
|
||||||
if (!(type = gst_structure_get_string (action->structure, "type")))
|
if (!(type = gst_structure_get_string (action->structure, "type")))
|
||||||
type = "audio";
|
type = "audio";
|
||||||
|
|
||||||
tflag =
|
tflag = gst_validate_utils_flags_from_str (g_type_from_name ("GstPlayFlags"),
|
||||||
gst_validate_utils_flags_from_str (g_type_from_name ("GstPlayFlags"),
|
|
||||||
type);
|
type);
|
||||||
current_txt = g_strdup_printf ("current-%s", type);
|
current_txt = g_strdup_printf ("current-%s", type);
|
||||||
|
|
||||||
|
@ -2897,7 +2896,6 @@ _load_scenario_file (GstValidateScenario * scenario,
|
||||||
const gchar *type;
|
const gchar *type;
|
||||||
GstStructure *structure = (GstStructure *) tmp->data;
|
GstStructure *structure = (GstStructure *) tmp->data;
|
||||||
|
|
||||||
|
|
||||||
type = gst_structure_get_name (structure);
|
type = gst_structure_get_name (structure);
|
||||||
if (!g_strcmp0 (type, "description")) {
|
if (!g_strcmp0 (type, "description")) {
|
||||||
const gchar *pipeline_name;
|
const gchar *pipeline_name;
|
||||||
|
|
|
@ -495,19 +495,18 @@ gst_validate_utils_parse_expression (const gchar * expr,
|
||||||
guint
|
guint
|
||||||
gst_validate_utils_flags_from_str (GType type, const gchar * str_flags)
|
gst_validate_utils_flags_from_str (GType type, const gchar * str_flags)
|
||||||
{
|
{
|
||||||
guint i;
|
guint flags;
|
||||||
gint flags = 0;
|
GValue value = G_VALUE_INIT;
|
||||||
GFlagsClass *class = g_type_class_ref (type);
|
g_value_init (&value, type);
|
||||||
|
|
||||||
for (i = 0; i < class->n_values; i++) {
|
if (!gst_value_deserialize (&value, str_flags)) {
|
||||||
if (class->values[i].value_nick == NULL)
|
g_error ("Invalid flags: %s", str_flags);
|
||||||
continue;
|
|
||||||
|
|
||||||
if (g_strrstr (str_flags, class->values[i].value_nick)) {
|
return 0;
|
||||||
flags |= class->values[i].value;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
g_type_class_unref (class);
|
flags = g_value_get_flags (&value);
|
||||||
|
g_value_unset (&value);
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
@ -524,20 +523,19 @@ gboolean
|
||||||
gst_validate_utils_enum_from_str (GType type, const gchar * str_enum,
|
gst_validate_utils_enum_from_str (GType type, const gchar * str_enum,
|
||||||
guint * enum_value)
|
guint * enum_value)
|
||||||
{
|
{
|
||||||
guint i;
|
GValue value = G_VALUE_INIT;
|
||||||
GEnumClass *class = g_type_class_ref (type);
|
g_value_init (&value, type);
|
||||||
gboolean ret = FALSE;
|
|
||||||
|
|
||||||
for (i = 0; i < class->n_values; i++) {
|
if (!gst_value_deserialize (&value, str_enum)) {
|
||||||
if (g_strrstr (str_enum, class->values[i].value_nick)) {
|
g_error ("Invalid enum: %s", str_enum);
|
||||||
*enum_value = class->values[i].value;
|
|
||||||
ret = TRUE;
|
return FALSE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_type_class_unref (class);
|
*enum_value = g_value_get_enum (&value);
|
||||||
|
g_value_unset (&value);
|
||||||
|
|
||||||
return ret;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse file that contains a list of GStructures */
|
/* Parse file that contains a list of GStructures */
|
||||||
|
|
Loading…
Reference in a new issue