mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:16:13 +00:00
validate:utils: Allow plain string in gst_validate_utils_get_strv
This commit is contained in:
parent
06f6fd8de1
commit
987d125c7e
1 changed files with 16 additions and 8 deletions
|
@ -1148,25 +1148,33 @@ gst_validate_set_globals (GstStructure * structure)
|
||||||
gchar **
|
gchar **
|
||||||
gst_validate_utils_get_strv (GstStructure * str, const gchar * fieldname)
|
gst_validate_utils_get_strv (GstStructure * str, const gchar * fieldname)
|
||||||
{
|
{
|
||||||
const GValue *list;
|
const GValue *value;
|
||||||
gchar **parsed_list;
|
gchar **parsed_list;
|
||||||
guint i, size;
|
guint i, size;
|
||||||
|
|
||||||
list = gst_structure_get_value (str, fieldname);
|
value = gst_structure_get_value (str, fieldname);
|
||||||
if (!list)
|
if (!value)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!GST_VALUE_HOLDS_LIST (list)) {
|
if (G_VALUE_HOLDS_STRING (value)) {
|
||||||
|
parsed_list = g_new0 (gchar *, 2);
|
||||||
|
parsed_list[0] = g_value_dup_string (value);
|
||||||
|
|
||||||
|
return parsed_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GST_VALUE_HOLDS_LIST (value)) {
|
||||||
g_error
|
g_error
|
||||||
("%s must have type list of string, e.g. %s={ val1, val2 }, got: \"%s\"",
|
("%s must have type list of string (or a string), e.g. %s={ val1, val2 }, got: \"%s\" in %s",
|
||||||
fieldname, fieldname, gst_value_serialize (list));
|
fieldname, fieldname, gst_value_serialize (value),
|
||||||
|
gst_structure_to_string (str));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = gst_value_list_get_size (list);
|
size = gst_value_list_get_size (value);
|
||||||
parsed_list = g_malloc_n (size + 1, sizeof (gchar *));
|
parsed_list = g_malloc_n (size + 1, sizeof (gchar *));
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
parsed_list[i] = g_value_dup_string (gst_value_list_get_value (list, i));
|
parsed_list[i] = g_value_dup_string (gst_value_list_get_value (value, i));
|
||||||
parsed_list[i] = NULL;
|
parsed_list[i] = NULL;
|
||||||
return parsed_list;
|
return parsed_list;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue