mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 11:55:39 +00:00
structure: Fix serializing with new format inside arrays/lists
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1554>
This commit is contained in:
parent
84c0d02755
commit
79e28368fc
4 changed files with 29 additions and 10 deletions
|
@ -167,7 +167,7 @@ G_GNUC_INTERNAL const char * _priv_gst_value_gtype_to_abbr (GType type);
|
|||
G_GNUC_INTERNAL gboolean _priv_gst_value_parse_string (gchar * s, gchar ** end, gchar ** next, gboolean unescape);
|
||||
G_GNUC_INTERNAL gboolean _priv_gst_value_parse_simple_string (gchar * str, gchar ** end);
|
||||
G_GNUC_INTERNAL gboolean _priv_gst_value_parse_value (gchar * str, gchar ** after, GValue * value, GType default_type, GParamSpec *pspec);
|
||||
G_GNUC_INTERNAL gchar * _priv_gst_value_serialize_any_list (const GValue * value, const gchar * begin, const gchar * end, gboolean print_type);
|
||||
G_GNUC_INTERNAL gchar * _priv_gst_value_serialize_any_list (const GValue * value, const gchar * begin, const gchar * end, gboolean print_type, GstSerializeFlags flags);
|
||||
|
||||
/* Used in GstBin for manual state handling */
|
||||
G_GNUC_INTERNAL void _priv_gst_element_state_changed (GstElement *element,
|
||||
|
|
|
@ -2044,9 +2044,11 @@ priv_gst_structure_append_to_gstring (const GstStructure * structure,
|
|||
field = GST_STRUCTURE_FIELD (structure, i);
|
||||
|
||||
if (G_VALUE_TYPE (&field->value) == GST_TYPE_ARRAY) {
|
||||
t = _priv_gst_value_serialize_any_list (&field->value, "< ", " >", FALSE);
|
||||
t = _priv_gst_value_serialize_any_list (&field->value, "< ", " >", FALSE,
|
||||
flags);
|
||||
} else if (G_VALUE_TYPE (&field->value) == GST_TYPE_LIST) {
|
||||
t = _priv_gst_value_serialize_any_list (&field->value, "{ ", " }", FALSE);
|
||||
t = _priv_gst_value_serialize_any_list (&field->value, "{ ", " }", FALSE,
|
||||
flags);
|
||||
} else if (!nested_structs_brackets
|
||||
|| (G_VALUE_TYPE (&field->value) != GST_TYPE_STRUCTURE
|
||||
&& G_VALUE_TYPE (&field->value) != GST_TYPE_CAPS)) {
|
||||
|
|
|
@ -348,7 +348,7 @@ gst_value_array_init (GValue * value, guint prealloc)
|
|||
*/
|
||||
gchar *
|
||||
_priv_gst_value_serialize_any_list (const GValue * value, const gchar * begin,
|
||||
const gchar * end, gboolean print_type)
|
||||
const gchar * end, gboolean print_type, GstSerializeFlags flags)
|
||||
{
|
||||
guint i;
|
||||
GstValueList *vlist = value->data[0].v_pointer;
|
||||
|
@ -361,15 +361,30 @@ _priv_gst_value_serialize_any_list (const GValue * value, const gchar * begin,
|
|||
s = g_string_sized_new (2 + (6 * alen) + 2);
|
||||
g_string_append (s, begin);
|
||||
for (i = 0; i < alen; i++) {
|
||||
gboolean nested_structs_brackets;
|
||||
v = &vlist->fields[i];
|
||||
s_val = gst_value_serialize (v);
|
||||
nested_structs_brackets = !(flags & GST_SERIALIZE_FLAG_BACKWARD_COMPAT)
|
||||
&& (GST_VALUE_HOLDS_STRUCTURE (v) || GST_VALUE_HOLDS_CAPS (v));
|
||||
if (!nested_structs_brackets) {
|
||||
s_val = gst_value_serialize (v);
|
||||
} else {
|
||||
if (GST_VALUE_HOLDS_STRUCTURE (v))
|
||||
s_val = gst_structure_serialize (gst_value_get_structure (v), flags);
|
||||
else if (GST_VALUE_HOLDS_CAPS (v))
|
||||
s_val = gst_caps_serialize (gst_value_get_caps (v), flags);
|
||||
}
|
||||
if (s_val != NULL) {
|
||||
if (print_type) {
|
||||
g_string_append_c (s, '(');
|
||||
g_string_append (s, _priv_gst_value_gtype_to_abbr (G_VALUE_TYPE (v)));
|
||||
g_string_append_c (s, ')');
|
||||
}
|
||||
|
||||
if (nested_structs_brackets)
|
||||
g_string_append_c (s, '[');
|
||||
g_string_append (s, s_val);
|
||||
if (nested_structs_brackets)
|
||||
g_string_append_c (s, ']');
|
||||
g_free (s_val);
|
||||
if (i < alen - 1) {
|
||||
g_string_append_len (s, ", ", 2);
|
||||
|
@ -1240,7 +1255,8 @@ gst_value_compare_g_value_array (const GValue * value1, const GValue * value2)
|
|||
static gchar *
|
||||
gst_value_serialize_value_list (const GValue * value)
|
||||
{
|
||||
return _priv_gst_value_serialize_any_list (value, "{ ", " }", TRUE);
|
||||
return _priv_gst_value_serialize_any_list (value, "{ ", " }", TRUE,
|
||||
GST_SERIALIZE_FLAG_BACKWARD_COMPAT);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -1254,7 +1270,8 @@ gst_value_deserialize_value_list (GValue * dest, const gchar * s,
|
|||
static gchar *
|
||||
gst_value_serialize_value_array (const GValue * value)
|
||||
{
|
||||
return _priv_gst_value_serialize_any_list (value, "< ", " >", TRUE);
|
||||
return _priv_gst_value_serialize_any_list (value, "< ", " >", TRUE,
|
||||
GST_SERIALIZE_FLAG_BACKWARD_COMPAT);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -779,7 +779,7 @@ GST_START_TEST (test_serialize_nested_structures)
|
|||
", main-sub1=(structure)[type-b, machine-type=(int)0;]"
|
||||
", main-sub2=(structure)[type-a, plugin-filename=(string)\"/home/user/lib/lib\\ with\\ spaces.dll\", machine-type=(int)1;]"
|
||||
", main-sub3=(structure)[type-b, plugin-filename=(string)/home/user/lib/lib_no_spaces.so, machine-type=(int)1;]"
|
||||
";";
|
||||
", main-sub4=(structure){ [s1, a=(int)1;], [s2, b=(int)2;] }" ";";
|
||||
|
||||
s = gst_structure_from_string (str1, &end);
|
||||
fail_unless (s != NULL);
|
||||
|
@ -787,7 +787,7 @@ GST_START_TEST (test_serialize_nested_structures)
|
|||
GST_DEBUG ("not parsed part : %s", end);
|
||||
fail_unless (*end == '\0');
|
||||
|
||||
fail_unless (gst_structure_n_fields (s) == 3);
|
||||
fail_unless (gst_structure_n_fields (s) == 4);
|
||||
|
||||
fail_unless (gst_structure_has_field_typed (s, "main-sub1",
|
||||
GST_TYPE_STRUCTURE));
|
||||
|
@ -795,7 +795,7 @@ GST_START_TEST (test_serialize_nested_structures)
|
|||
str2 = gst_structure_serialize (s, GST_SERIALIZE_FLAG_NONE);
|
||||
fail_unless (str2 != NULL);
|
||||
|
||||
fail_unless (g_str_equal (str1, str2));
|
||||
fail_unless_equals_string (str1, str2);
|
||||
|
||||
g_free (str2);
|
||||
|
||||
|
|
Loading…
Reference in a new issue