mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
value: fix caps serialization when there are caps inside caps
Wrap caps strings so that it can handle serialization and deserialization of caps inside caps. Otherwise the values from the internal caps are parsed as if they were from the upper one https://bugzilla.gnome.org/show_bug.cgi?id=708772
This commit is contained in:
parent
3892e4dd61
commit
007c0e5fe1
4 changed files with 43 additions and 4 deletions
|
@ -56,6 +56,12 @@
|
||||||
* Various methods exist to work with the media types such as subtracting
|
* Various methods exist to work with the media types such as subtracting
|
||||||
* or intersecting.
|
* or intersecting.
|
||||||
*
|
*
|
||||||
|
* Be aware that the current #GstCaps / #GstStructure serialization into string
|
||||||
|
* has limited support for nested #GstCaps / #GstStructure fields. It can only
|
||||||
|
* support one level of nesting. Using more levels will lead to unexpected
|
||||||
|
* behavior when using serialization features, such as gst_caps_to_string() or
|
||||||
|
* gst_value_serialize() and their counterparts.
|
||||||
|
*
|
||||||
* Last reviewed on 2011-03-28 (0.11.3)
|
* Last reviewed on 2011-03-28 (0.11.3)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2129,6 +2135,9 @@ gst_caps_fixate (GstCaps * caps)
|
||||||
* ]|
|
* ]|
|
||||||
* This prints the caps in human readable form.
|
* This prints the caps in human readable form.
|
||||||
*
|
*
|
||||||
|
* The current implementation of serialization will lead to unexpected results
|
||||||
|
* when there are nested #GstCaps / #GstStructure deeper than one level.
|
||||||
|
*
|
||||||
* Returns: (transfer full): a newly allocated string representing @caps.
|
* Returns: (transfer full): a newly allocated string representing @caps.
|
||||||
*/
|
*/
|
||||||
gchar *
|
gchar *
|
||||||
|
@ -2298,6 +2307,9 @@ gst_caps_from_string_inplace (GstCaps * caps, const gchar * string)
|
||||||
*
|
*
|
||||||
* Converts @caps from a string representation.
|
* Converts @caps from a string representation.
|
||||||
*
|
*
|
||||||
|
* The current implementation of serialization will lead to unexpected results
|
||||||
|
* when there are nested #GstCaps / #GstStructure deeper than one level.
|
||||||
|
*
|
||||||
* Returns: (transfer full): a newly allocated #GstCaps
|
* Returns: (transfer full): a newly allocated #GstCaps
|
||||||
*/
|
*/
|
||||||
GstCaps *
|
GstCaps *
|
||||||
|
|
|
@ -53,6 +53,12 @@
|
||||||
* Strings in structures must be ASCII or UTF-8 encoded. Other encodings are
|
* Strings in structures must be ASCII or UTF-8 encoded. Other encodings are
|
||||||
* not allowed. Strings must not be empty either, but may be NULL.
|
* not allowed. Strings must not be empty either, but may be NULL.
|
||||||
*
|
*
|
||||||
|
* Be aware that the current #GstCaps / #GstStructure serialization into string
|
||||||
|
* has limited support for nested #GstCaps / #GstStructure fields. It can only
|
||||||
|
* support one level of nesting. Using more levels will lead to unexpected
|
||||||
|
* behavior when using serialization features, such as gst_caps_to_string() or
|
||||||
|
* gst_value_serialize() and their counterparts.
|
||||||
|
*
|
||||||
* Last reviewed on 2012-03-29 (0.11.3)
|
* Last reviewed on 2012-03-29 (0.11.3)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1817,6 +1823,9 @@ priv_gst_structure_append_to_gstring (const GstStructure * structure,
|
||||||
* ]|
|
* ]|
|
||||||
* This prints the structure in human readble form.
|
* This prints the structure in human readble form.
|
||||||
*
|
*
|
||||||
|
* The current implementation of serialization will lead to unexpected results
|
||||||
|
* when there are nested #GstCaps / #GstStructure deeper than one level.
|
||||||
|
*
|
||||||
* Free-function: g_free
|
* Free-function: g_free
|
||||||
*
|
*
|
||||||
* Returns: (transfer full): a pointer to string allocated by g_malloc().
|
* Returns: (transfer full): a pointer to string allocated by g_malloc().
|
||||||
|
@ -2315,6 +2324,9 @@ priv_gst_structure_parse_fields (gchar * str, gchar ** end,
|
||||||
* If end is not NULL, a pointer to the place inside the given string
|
* If end is not NULL, a pointer to the place inside the given string
|
||||||
* where parsing ended will be returned.
|
* where parsing ended will be returned.
|
||||||
*
|
*
|
||||||
|
* The current implementation of serialization will lead to unexpected results
|
||||||
|
* when there are nested #GstCaps / #GstStructure deeper than one level.
|
||||||
|
*
|
||||||
* Free-function: gst_structure_free
|
* Free-function: gst_structure_free
|
||||||
*
|
*
|
||||||
* Returns: (transfer full): a new #GstStructure or NULL when the string could
|
* Returns: (transfer full): a new #GstStructure or NULL when the string could
|
||||||
|
|
|
@ -1887,8 +1887,7 @@ static gchar *
|
||||||
gst_value_serialize_caps (const GValue * value)
|
gst_value_serialize_caps (const GValue * value)
|
||||||
{
|
{
|
||||||
GstCaps *caps = g_value_get_boxed (value);
|
GstCaps *caps = g_value_get_boxed (value);
|
||||||
|
return gst_string_take_and_wrap (gst_caps_to_string (caps));
|
||||||
return gst_caps_to_string (caps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -1896,7 +1895,17 @@ gst_value_deserialize_caps (GValue * dest, const gchar * s)
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
caps = gst_caps_from_string (s);
|
if (*s != '"') {
|
||||||
|
caps = gst_caps_from_string (s);
|
||||||
|
} else {
|
||||||
|
gchar *str = gst_string_unwrap (s);
|
||||||
|
|
||||||
|
if (G_UNLIKELY (!str))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
caps = gst_caps_from_string (str);
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
|
|
||||||
if (caps) {
|
if (caps) {
|
||||||
g_value_take_boxed (dest, caps);
|
g_value_take_boxed (dest, caps);
|
||||||
|
|
|
@ -2379,11 +2379,17 @@ GST_START_TEST (test_serialize_deserialize_caps)
|
||||||
, value2 = {
|
, value2 = {
|
||||||
0};
|
0};
|
||||||
GstCaps *caps, *caps2;
|
GstCaps *caps, *caps2;
|
||||||
|
GstCaps *incaps;
|
||||||
gchar *serialized;
|
gchar *serialized;
|
||||||
|
|
||||||
|
incaps = gst_caps_new_simple ("caps/internal",
|
||||||
|
"in-field", G_TYPE_INT, 20, "in-field2",
|
||||||
|
G_TYPE_STRING, "some in ternal field", NULL);
|
||||||
caps = gst_caps_new_simple ("test/caps",
|
caps = gst_caps_new_simple ("test/caps",
|
||||||
"foo", G_TYPE_INT, 10, "bar", G_TYPE_STRING, "test", NULL);
|
"foo", G_TYPE_INT, 10, "bar", G_TYPE_STRING, "test",
|
||||||
|
"int-caps", GST_TYPE_CAPS, incaps, NULL);
|
||||||
fail_if (GST_CAPS_REFCOUNT_VALUE (caps) != 1);
|
fail_if (GST_CAPS_REFCOUNT_VALUE (caps) != 1);
|
||||||
|
gst_caps_unref (incaps);
|
||||||
|
|
||||||
/* and assign caps to gvalue */
|
/* and assign caps to gvalue */
|
||||||
g_value_init (&value, GST_TYPE_CAPS);
|
g_value_init (&value, GST_TYPE_CAPS);
|
||||||
|
|
Loading…
Reference in a new issue