Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1554>
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,
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)) {
*/
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;
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);
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
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
", 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);
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));
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);