gst_caps_to_string: print NULL caps correctly
[platform/upstream/gstreamer.git] / gst / gstelementfactory.c
index 3884049..78f00fd 100644 (file)
@@ -24,7 +24,7 @@
 #include "gst_private.h"
 
 #include "gstelement.h"
-#include "gstregistry.h"
+#include "gstregistrypool.h"
 #include "gstlog.h"
 
 static void            gst_element_factory_class_init          (GstElementFactoryClass *klass);
@@ -110,23 +110,43 @@ gst_element_factory_find (const gchar *name)
 static void
 gst_element_details_free (GstElementDetails *dp)
 {
-  g_return_if_fail (dp);
-
-  if (dp->longname)
-    g_free (dp->longname);
-  if (dp->klass)
-    g_free (dp->klass);
-  if (dp->description)
-    g_free (dp->description);
-  if (dp->version)
-    g_free (dp->version);
-  if (dp->author)
-    g_free (dp->author);
-  if (dp->copyright)
-    g_free (dp->copyright);
+  g_free (dp->longname);
+  g_free (dp->klass);
+  g_free (dp->license);
+  g_free (dp->description);
+  g_free (dp->version);
+  g_free (dp->author);
+  g_free (dp->copyright);
   g_free (dp);
 }
 
+static void
+gst_element_factory_cleanup (GstElementFactory *factory)
+{
+  GList *padtemplates;
+
+  if (factory->details_dynamic) {
+    gst_element_details_free (factory->details);
+    factory->details_dynamic = FALSE;
+  }
+
+  padtemplates = factory->padtemplates;
+
+  while (padtemplates) {
+    GstPadTemplate *oldtempl = GST_PAD_TEMPLATE (padtemplates->data);
+     
+    gst_object_unref (GST_OBJECT (oldtempl));
+
+    padtemplates = g_list_next (padtemplates);
+  }
+  g_list_free (factory->padtemplates);
+
+  factory->padtemplates = NULL;
+  factory->numpadtemplates = 0;
+
+  g_free (GST_PLUGIN_FEATURE (factory)->name);
+}
+
 /**
  * gst_element_factory_new:
  * @name: name of new elementfactory
@@ -152,13 +172,12 @@ gst_element_factory_new (const gchar *name, GType type,
 
   if (!factory)
     factory = GST_ELEMENT_FACTORY (g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL));
-
-  if (factory->details_dynamic) {
-    gst_element_details_free (factory->details);
-    factory->details_dynamic = FALSE;
+  else {
+    gst_element_factory_cleanup (factory);
   }
 
   factory->details = details;
+  factory->details_dynamic = FALSE;
 
   if (!factory->type)
     factory->type = type;
@@ -181,7 +200,7 @@ gst_element_factory_new (const gchar *name, GType type,
  *
  * Returns: new #GstElement
  */
-GstElement *
+GstElement*
 gst_element_factory_create (GstElementFactory *factory,
                            const gchar *name)
 {
@@ -195,7 +214,7 @@ gst_element_factory_create (GstElementFactory *factory,
 
   GST_DEBUG (GST_CAT_ELEMENT_FACTORY,
              "creating element from factory \"%s\" (name \"%s\", type %d)", 
-             GST_OBJECT_NAME (factory), name, (gint) factory->type);
+             GST_PLUGIN_FEATURE_NAME (factory), GST_STR_NULL (name), (gint) factory->type);
 
   if (factory->type == 0) {
       g_critical ("Factory for `%s' has no type",
@@ -210,7 +229,7 @@ gst_element_factory_create (GstElementFactory *factory,
   /* attempt to set the elemenfactory class pointer if necessary */
   oclass = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
   if (oclass->elementfactory == NULL) {
-    GST_DEBUG (GST_CAT_ELEMENT_FACTORY, "class %s", GST_OBJECT_NAME (factory));
+    GST_DEBUG (GST_CAT_ELEMENT_FACTORY, "class %s", GST_PLUGIN_FEATURE_NAME (factory));
     oclass->elementfactory = factory;
 
     /* copy pad template pointers to the element class, 
@@ -246,7 +265,7 @@ gst_element_factory_make (const gchar *factoryname, const gchar *name)
   g_return_val_if_fail (factoryname != NULL, NULL);
 
   GST_DEBUG (GST_CAT_ELEMENT_FACTORY, "gstelementfactory: make \"%s\" \"%s\"", 
-             factoryname, name);
+             factoryname, GST_STR_NULL (name));
 
   /* gst_plugin_load_element_factory (factoryname); */
   factory = gst_element_factory_find (factoryname);
@@ -280,7 +299,9 @@ gst_element_factory_make (const gchar *factoryname, const gchar *name)
 GstElement*
 gst_element_factory_make_or_warn (const gchar *factoryname, const gchar *name)
 {
-  GstElement *element = gst_element_factory_make (factoryname, name);
+  GstElement *element;
+  
+  element = gst_element_factory_make (factoryname, name);
 
   if (element == NULL) 
     g_warning ("Could not create element from factory %s !\n", factoryname);
@@ -297,28 +318,14 @@ gst_element_factory_make_or_warn (const gchar *factoryname, const gchar *name)
  */
 void
 gst_element_factory_add_pad_template (GstElementFactory *factory,
-                                   GstPadTemplate *templ)
+                                     GstPadTemplate *templ)
 {
-  GList *padtemplates;
-  
-  g_return_if_fail(factory != NULL);
-  g_return_if_fail(templ != NULL);
-
-  padtemplates = factory->padtemplates;
+  g_return_if_fail (factory != NULL);
+  g_return_if_fail (templ != NULL);
 
   gst_object_ref (GST_OBJECT (templ));
+  gst_object_sink (GST_OBJECT (templ));
 
-  while (padtemplates) {
-    GstPadTemplate *oldtempl = GST_PAD_TEMPLATE (padtemplates->data);
-    
-    if (!strcmp (oldtempl->name_template, templ->name_template)) {
-      gst_object_unref (GST_OBJECT (oldtempl));
-      padtemplates->data = templ;
-      return;
-    }
-    
-    padtemplates = g_list_next (padtemplates);
-  }
   factory->padtemplates = g_list_append (factory->padtemplates, templ);
   factory->numpadtemplates++;
 }
@@ -347,7 +354,7 @@ gst_element_factory_can_src_caps (GstElementFactory *factory,
     GstPadTemplate *template = (GstPadTemplate *)templates->data;
 
     if (template->direction == GST_PAD_SRC) {
-      if (gst_caps_check_compatibility (GST_PAD_TEMPLATE_CAPS (template), caps))
+      if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template), caps))
        return TRUE;
     }
     templates = g_list_next (templates);
@@ -380,7 +387,7 @@ gst_element_factory_can_sink_caps (GstElementFactory *factory,
     GstPadTemplate *template = (GstPadTemplate *)templates->data;
 
     if (template->direction == GST_PAD_SINK) {
-      if (gst_caps_check_compatibility (caps, GST_PAD_TEMPLATE_CAPS (template)))
+      if (gst_caps_is_always_compatible (caps, GST_PAD_TEMPLATE_CAPS (template)))
        return TRUE;
     }
     templates = g_list_next (templates);
@@ -401,7 +408,7 @@ gst_element_factory_can_sink_caps (GstElementFactory *factory,
 void
 gst_element_factory_set_rank (GstElementFactory *factory, guint16 rank)
 {
-  g_return_if_fail(factory != NULL);
+  g_return_if_fail (factory != NULL);
   factory->rank = rank;
 }