summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sf.net>2009-08-31 19:48:01 (GMT)
committerStefan Kost <ensonic@users.sf.net>2009-08-31 19:48:01 (GMT)
commite7368354d514117c05636fca816966caba5ce0ed (patch)
tree996517de5ddf9a18a473840365d72421287022d2
parent2194166e05fc7013f41eba9e76480afb838c2094 (diff)
adder: improve caps filter functionality. Fixes #590146.
Also use the capsfilter if there is no src-peer as the caps constrain what we can do. Don't create any_caps as a default, as we check for NULL to skip the filtering. This is a (small) performance regression as we always intersect otherwise.
-rw-r--r--gst/adder/gstadder.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c
index 3f067d0..3684624 100644
--- a/gst/adder/gstadder.c
+++ b/gst/adder/gstadder.c
@@ -244,6 +244,7 @@ gst_adder_sink_getcaps (GstPad * pad)
if (peercaps) {
/* restrict with filter-caps if any */
if (adder->filter_caps) {
+ GST_DEBUG_OBJECT (adder, "filtering peer caps");
result = gst_caps_intersect (peercaps, adder->filter_caps);
gst_caps_unref (peercaps);
peercaps = result;
@@ -256,8 +257,15 @@ gst_adder_sink_getcaps (GstPad * pad)
} else {
/* the peer has no caps (or there is no peer), just use the allowed caps
* of this sinkpad. */
- GST_DEBUG_OBJECT (adder, "no peer caps, using sinkcaps");
- result = sinkcaps;
+ /* restrict with filter-caps if any */
+ if (adder->filter_caps) {
+ GST_DEBUG_OBJECT (adder, "no peer caps, using filtered sinkcaps");
+ result = gst_caps_intersect (sinkcaps, adder->filter_caps);
+ gst_caps_unref (sinkcaps);
+ } else {
+ GST_DEBUG_OBJECT (adder, "no peer caps, using sinkcaps");
+ result = sinkcaps;
+ }
}
GST_OBJECT_UNLOCK (adder);
@@ -868,7 +876,7 @@ gst_adder_init (GstAdder * adder)
adder->padcount = 0;
adder->func = NULL;
- adder->filter_caps = gst_caps_new_any ();
+ adder->filter_caps = NULL;
/* keep track of the sinkpads requested */
adder->collect = gst_collect_pads_new ();
@@ -903,13 +911,11 @@ gst_adder_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_FILTER_CAPS:{
- GstCaps *new_caps;
+ GstCaps *new_caps = NULL;
GstCaps *old_caps;
const GstCaps *new_caps_val = gst_value_get_caps (value);
- if (new_caps_val == NULL) {
- new_caps = gst_caps_new_any ();
- } else {
+ if (new_caps_val != NULL) {
new_caps = (GstCaps *) new_caps_val;
gst_caps_ref (new_caps);
}
@@ -919,7 +925,8 @@ gst_adder_set_property (GObject * object, guint prop_id,
adder->filter_caps = new_caps;
GST_OBJECT_UNLOCK (adder);
- gst_caps_unref (old_caps);
+ if (old_caps)
+ gst_caps_unref (old_caps);
GST_DEBUG_OBJECT (adder, "set new caps %" GST_PTR_FORMAT, new_caps);
break;