pad: add ACCEPT_INTERCEPT flag

Make a new flag on the pad that tweaks the default behaviour of the
accept-caps function. By default it will check for a subset of the
query-caps result but this is not always desirable. The query-caps
result contains all the constraints to make a good caps decision
upstream but sometimes, like for parsers, not all the constrained caps
fields are known upstream and then a subset check would fail. Switching
to an intersection makes this work again.

See https://bugzilla.gnome.org/show_bug.cgi?id=705024
    https://bugzilla.gnome.org/show_bug.cgi?id=677401
This commit is contained in:
Wim Taymans 2013-12-03 21:46:19 +01:00
parent a90ce304c8
commit 34db352879
2 changed files with 19 additions and 2 deletions

View file

@ -2830,8 +2830,16 @@ gst_pad_query_accept_caps_default (GstPad * pad, GstQuery * query)
allowed = gst_pad_query_caps (pad, caps);
if (allowed) {
GST_DEBUG_OBJECT (pad, "allowed caps %" GST_PTR_FORMAT, allowed);
result = gst_caps_is_subset (caps, allowed);
if (GST_PAD_IS_ACCEPT_INTERSECT (pad)) {
GST_DEBUG_OBJECT (pad,
"allowed caps intersect %" GST_PTR_FORMAT ", caps %" GST_PTR_FORMAT,
allowed, caps);
result = gst_caps_can_intersect (caps, allowed);
} else {
GST_DEBUG_OBJECT (pad, "allowed caps subset %" GST_PTR_FORMAT ", caps %"
GST_PTR_FORMAT, allowed, caps);
result = gst_caps_is_subset (caps, allowed);
}
gst_caps_unref (allowed);
} else {
GST_DEBUG_OBJECT (pad, "no compatible caps allowed on the pad");

View file

@ -622,6 +622,10 @@ typedef gboolean (*GstPadStickyEventsForeachFunction) (GstPad *pad, GstEvent **
* @GST_PAD_FLAG_PROXY_SCHEDULING: the default query handler will forward
* scheduling queries to the internally linked pads
* instead of discarding them.
* @GST_PAD_FLAG_ACCEPT_INTERSECT: the default accept-caps handler will check
* it the caps intersect the query-caps result instead
* of checking for a subset. This is interesting for
* parsers that can accept incompletely specified caps.
* @GST_PAD_FLAG_LAST: offset to define more flags
*
* Pad state flags
@ -638,6 +642,7 @@ typedef enum {
GST_PAD_FLAG_PROXY_CAPS = (GST_OBJECT_FLAG_LAST << 8),
GST_PAD_FLAG_PROXY_ALLOCATION = (GST_OBJECT_FLAG_LAST << 9),
GST_PAD_FLAG_PROXY_SCHEDULING = (GST_OBJECT_FLAG_LAST << 10),
GST_PAD_FLAG_ACCEPT_INTERSECT = (GST_OBJECT_FLAG_LAST << 11),
/* padding */
GST_PAD_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 16)
} GstPadFlags;
@ -791,6 +796,10 @@ struct _GstPadClass {
#define GST_PAD_SET_PROXY_SCHEDULING(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PROXY_SCHEDULING))
#define GST_PAD_UNSET_PROXY_SCHEDULING(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PROXY_SCHEDULING))
#define GST_PAD_IS_ACCEPT_INTERSECT(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT))
#define GST_PAD_SET_ACCEPT_INTERSECT(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT))
#define GST_PAD_UNSET_ACCEPT_INTERSECT(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT))
/**
* GST_PAD_GET_STREAM_LOCK:
* @pad: a #GstPad