summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sf.net>2009-08-31 22:48:01 +0300
committerStefan Kost <ensonic@users.sf.net>2009-08-31 22:48:01 +0300
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.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c
index 3f067d030..36846245a 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,9 +257,16 @@ 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. */
+ /* 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);
GST_LOG_OBJECT (adder, "getting caps on pad %p,%s to %" GST_PTR_FORMAT, pad,
@@ -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,6 +925,7 @@ gst_adder_set_property (GObject * object, guint prop_id,
adder->filter_caps = new_caps;
GST_OBJECT_UNLOCK (adder);
+ if (old_caps)
gst_caps_unref (old_caps);
GST_DEBUG_OBJECT (adder, "set new caps %" GST_PTR_FORMAT, new_caps);