- Added value transform functions for caps and props boxed types
[platform/upstream/gstreamer.git] / gst / gstcaps.c
index da1bd48..f7ed767 100644 (file)
 
 #include "gstcaps.h"
 #include "gsttype.h"
+#include "gstlog.h"
 
 static GMemChunk *_gst_caps_chunk;
 static GMutex *_gst_caps_chunk_lock;
 
 GType _gst_caps_type;
 
+static void
+transform_func (const GValue *src_value,
+               GValue *dest_value)
+{
+  GstCaps *caps = g_value_peek_pointer (src_value);
+  GString *result = g_string_new (""); 
+
+  g_string_append_printf (result, "(GstCaps *) ");
+                 
+  while (caps) {
+    gchar *props;
+    GValue value = { 0, }; /* the important thing is that value.type = 0 */
+    
+    g_string_append_printf (result,
+                 "{ %s; ", gst_caps_get_mime (caps));
+
+    g_value_init (&value, GST_TYPE_PROPS);
+    g_value_set_boxed  (&value, caps->properties);
+    props = g_strdup_value_contents (&value);
+
+    g_string_append (result, props);
+    g_free (props);
+
+    caps = caps->next;
+    g_string_append_printf (result, " }%s", caps?", ":"");
+  }
+  dest_value->data[0].v_pointer = result->str;
+}
+
 void
 _gst_caps_initialize (void)
 {
@@ -43,6 +73,9 @@ _gst_caps_initialize (void)
                                        (GBoxedCopyFunc) gst_caps_ref,
                                        (GBoxedFreeFunc) gst_caps_unref);
 
+  g_value_register_transform_func (_gst_caps_type,
+                                  G_TYPE_STRING,
+                                  transform_func);
 }
 
 static guint16
@@ -60,7 +93,7 @@ get_type_for_mime (const gchar *mime)
      definition.exts = NULL;
      definition.typefindfunc = NULL;
 
-     factory = gst_typefactory_new (&definition);
+     factory = gst_type_factory_new (&definition);
 
      typeid = gst_type_register (factory);
   }
@@ -131,7 +164,7 @@ gst_caps_destroy (GstCaps *caps)
 
   if (caps == NULL)
     return;
-  
+
   next = caps->next;
 
   gst_props_unref (caps->properties);
@@ -156,7 +189,8 @@ gst_caps_debug (GstCaps *caps, const gchar *label)
 {
   GST_DEBUG_ENTER ("caps debug: %s", label);
   while (caps) {
-    GST_DEBUG (GST_CAT_CAPS, "caps: %p %s %s", caps, caps->name, gst_caps_get_mime (caps));
+    GST_DEBUG (GST_CAT_CAPS, "caps: %p %s %s (%sfixed)", caps, caps->name, gst_caps_get_mime (caps), 
+               caps->fixed ? "" : "NOT ");
 
     if (caps->properties) {
       gst_props_debug (caps->properties);