gst/elements/gstcapsfilter.c: Free existing caps if the capsfilter changes. Add a...
authorJan Schmidt <thaytan@mad.scientist.com>
Thu, 2 Jun 2005 15:45:16 +0000 (15:45 +0000)
committerJan Schmidt <thaytan@mad.scientist.com>
Thu, 2 Jun 2005 15:45:16 +0000 (15:45 +0000)
Original commit message from CVS:
* gst/elements/gstcapsfilter.c: (gst_capsfilter_set_property):
Free existing caps if the capsfilter changes. Add a FIXME about
setting those caps on the pads.

* gst/gstutils.c: (gst_element_get_compatible_pad), (ghost_up):
Before adding a ghost pad to a parent bin, check that there isn't
already one for the element on the bin. Prevents infinite recursion
when using decodebin in parse pipelines. Andy says he'll rewrite the
way this works anyway, so ignore the hack.

ChangeLog
gst/elements/gstcapsfilter.c
gst/gstutils.c
plugins/elements/gstcapsfilter.c

index b7270df..9259e93 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-06-03  Jan Schmidt  <thaytan@mad.scientist.com>
+
+  * gst/elements/gstcapsfilter.c: (gst_capsfilter_set_property):
+    Free existing caps if the capsfilter changes. Add a FIXME about
+    setting those caps on the pads.
+
+  * gst/gstutils.c: (gst_element_get_compatible_pad), (ghost_up):
+    Before adding a ghost pad to a parent bin, check that there isn't
+    already one for the element on the bin. Prevents infinite recursion
+    when using decodebin in parse pipelines. Andy says he'll rewrite the
+    way this works anyway, so ignore the hack.
+
 2005-06-02  Andy Wingo  <wingo@pobox.com>
 
        * gst/elements/gsttypefindelement.c (do_pull_typefind): Query the
index 2081312..d478588 100644 (file)
@@ -205,9 +205,17 @@ gst_capsfilter_set_property (GObject * object, guint prop_id,
   capsfilter = GST_CAPSFILTER (object);
 
   switch (prop_id) {
-    case PROP_FILTER_CAPS:
-      capsfilter->filter_caps = gst_caps_copy (gst_value_get_caps (value));
+    case PROP_FILTER_CAPS:{
+      GstCaps *new_caps = gst_caps_copy (gst_value_get_caps (value));
+
+      g_return_if_fail (new_caps != NULL);
+
+      gst_caps_unref (capsfilter->filter_caps);
+      capsfilter->filter_caps = new_caps;
+
+      /* FIXME: Need to activate these caps on the pads */
       break;
+    }
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
index 1a50035..be1b064 100644 (file)
@@ -625,7 +625,7 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
 
         current = GST_PAD (padptr);
 
-        GST_CAT_LOG (GST_CAT_ELEMENT_PADS, "examing pad %s:%s",
+        GST_CAT_LOG (GST_CAT_ELEMENT_PADS, "examining pad %s:%s",
             GST_DEBUG_PAD_NAME (current));
 
         peer = gst_pad_get_peer (current);
@@ -808,14 +808,26 @@ ghost_up (GstElement * e, GstPad * pad)
   static gint ghost_pad_index = 0;
   GstPad *gpad;
   gchar *name;
+  GList *gpads;
+  GstObject *parent = GST_OBJECT_PARENT (e);
+
+  /* Check if the pad already has a ghost on the element */
+  for (gpads = g_list_first (GST_PAD_REALIZE (pad)->ghostpads); gpads != NULL;
+      gpads = g_list_next (gpads)) {
+    if (GST_OBJECT_PARENT (GST_PAD (gpads->data)) == parent) {
+      GST_DEBUG ("Found existing ghost pad of %s on element %s\n",
+          GST_OBJECT_NAME (pad), GST_OBJECT_NAME (parent));
+      return GST_PAD (gpads->data);
+    }
+  }
 
   name = g_strdup_printf ("ghost%d", ghost_pad_index++);
   gpad = gst_ghost_pad_new (name, pad);
   g_free (name);
 
-  if (!gst_element_add_pad ((GstElement *) GST_OBJECT_PARENT (e), gpad)) {
+  if (!gst_element_add_pad ((GstElement *) parent, gpad)) {
     g_warning ("Pad named %s already exists in element %s\n",
-        GST_OBJECT_NAME (gpad), GST_OBJECT_NAME (GST_OBJECT_PARENT (e)));
+        GST_OBJECT_NAME (gpad), GST_OBJECT_NAME (parent));
     gst_object_unref ((GstObject *) gpad);
     return NULL;
   }
index 2081312..d478588 100644 (file)
@@ -205,9 +205,17 @@ gst_capsfilter_set_property (GObject * object, guint prop_id,
   capsfilter = GST_CAPSFILTER (object);
 
   switch (prop_id) {
-    case PROP_FILTER_CAPS:
-      capsfilter->filter_caps = gst_caps_copy (gst_value_get_caps (value));
+    case PROP_FILTER_CAPS:{
+      GstCaps *new_caps = gst_caps_copy (gst_value_get_caps (value));
+
+      g_return_if_fail (new_caps != NULL);
+
+      gst_caps_unref (capsfilter->filter_caps);
+      capsfilter->filter_caps = new_caps;
+
+      /* FIXME: Need to activate these caps on the pads */
       break;
+    }
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;