basetransform: Always intersect the suggested sink caps with the peer caps

This makes sure that we get correct and complete caps. The suggested caps
could be incomplete, e.g. video/x-raw-rgb without any fields, and by
intersecting with the peer caps we get something usable.

Fixes bug #662199.
This commit is contained in:
Sebastian Dröge 2011-11-30 13:59:46 +01:00
parent c9bd4e4e96
commit e6d2da7cf8

View file

@ -1882,27 +1882,29 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
/* check if we actually handle this format on the sinkpad */
if (sink_suggest) {
const GstCaps *templ;
GstCaps *peercaps;
if (!gst_caps_is_fixed (sink_suggest)) {
GstCaps *peercaps;
/* Always intersect with the peer caps to get correct
* and complete caps. The suggested caps could be incomplete,
* for example video/x-raw-yuv without any fields at all.
*/
peercaps =
gst_pad_peer_get_caps_reffed (GST_BASE_TRANSFORM_SINK_PAD (trans));
if (peercaps) {
GstCaps *intersect;
intersect =
gst_caps_intersect_full (sink_suggest, peercaps,
GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (peercaps);
gst_caps_unref (sink_suggest);
sink_suggest = intersect;
}
if (!gst_caps_is_fixed (sink_suggest) || gst_caps_is_empty (sink_suggest)) {
GST_DEBUG_OBJECT (trans, "Suggested caps is not fixed: %"
GST_PTR_FORMAT, sink_suggest);
peercaps =
gst_pad_peer_get_caps_reffed (GST_BASE_TRANSFORM_SINK_PAD (trans));
/* try fixating by intersecting with peer caps */
if (peercaps) {
GstCaps *intersect;
intersect =
gst_caps_intersect_full (sink_suggest, peercaps,
GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (peercaps);
gst_caps_unref (sink_suggest);
sink_suggest = intersect;
}
if (gst_caps_is_empty (sink_suggest))
goto not_supported;