From c9f30f98b79c0aa471f38b062f889420d8ba85aa Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Thu, 2 Jun 2005 15:45:16 +0000 Subject: [PATCH] gst/elements/gstcapsfilter.c: Free existing caps if the capsfilter changes. Add a FIXME about setting those caps on t... 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 | 12 ++++++++++++ gst/elements/gstcapsfilter.c | 12 ++++++++++-- gst/gstutils.c | 18 +++++++++++++++--- plugins/elements/gstcapsfilter.c | 12 ++++++++++-- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index b7270df52e..9259e9378a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-06-03 Jan Schmidt + + * 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 * gst/elements/gsttypefindelement.c (do_pull_typefind): Query the diff --git a/gst/elements/gstcapsfilter.c b/gst/elements/gstcapsfilter.c index 2081312d0e..d478588f1c 100644 --- a/gst/elements/gstcapsfilter.c +++ b/gst/elements/gstcapsfilter.c @@ -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; diff --git a/gst/gstutils.c b/gst/gstutils.c index 1a5003538a..be1b064f4e 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -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; } diff --git a/plugins/elements/gstcapsfilter.c b/plugins/elements/gstcapsfilter.c index 2081312d0e..d478588f1c 100644 --- a/plugins/elements/gstcapsfilter.c +++ b/plugins/elements/gstcapsfilter.c @@ -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;