gst_structure_to_string: display actual value of pointers
[platform/upstream/gstreamer.git] / gst / gststructure.c
index 5be496b..5f7aad2 100644 (file)
@@ -879,7 +879,8 @@ gst_structure_get_field (const GstStructure * structure,
  *
  * Get the value of the field with name @fieldname.
  *
- * Returns: the #GValue corresponding to the field with the given name.
+ * Returns: (nullable): the #GValue corresponding to the field with the given
+ * name.
  */
 const GValue *
 gst_structure_get_value (const GstStructure * structure,
@@ -904,8 +905,8 @@ gst_structure_get_value (const GstStructure * structure,
  *
  * Get the value of the field with GQuark @field.
  *
- * Returns: the #GValue corresponding to the field with the given name
- *          identifier.
+ * Returns: (nullable): the #GValue corresponding to the field with the given
+ * name identifier.
  */
 const GValue *
 gst_structure_id_get_value (const GstStructure * structure, GQuark field)
@@ -1822,10 +1823,19 @@ priv_gst_structure_append_to_gstring (const GstStructure * structure,
     if (t) {
       g_string_append (s, t);
       g_free (t);
+    } else if (G_TYPE_CHECK_VALUE_TYPE (&field->value, G_TYPE_POINTER)) {
+      gpointer ptr = g_value_get_pointer (&field->value);
+
+      if (!ptr)
+        g_string_append (s, "NULL");
+      else
+        g_string_append_printf (s, "%p", ptr);
     } else {
-      GST_WARNING ("No value transform to serialize field '%s' of type '%s'",
-          g_quark_to_string (field->name),
-          _priv_gst_value_gtype_to_abbr (type));
+      if (!G_TYPE_CHECK_VALUE_TYPE (&field->value, G_TYPE_STRING))
+        GST_WARNING ("No value transform to serialize field '%s' of type '%s'",
+            g_quark_to_string (field->name),
+            _priv_gst_value_gtype_to_abbr (type));
+      /* TODO(ensonic): don't print NULL if field->value is not empty */
       g_string_append (s, "NULL");
     }
   }
@@ -2844,7 +2854,7 @@ gst_structure_intersect_field2 (GQuark id, const GValue * val1, gpointer data)
  *
  * Intersects @struct1 and @struct2 and returns the intersection.
  *
- * Returns: Intersection of @struct1 and @struct2
+ * Returns: (nullable): Intersection of @struct1 and @struct2
  */
 GstStructure *
 gst_structure_intersect (const GstStructure * struct1,