pads: Improve readability for gst_pad_fixate_caps()

Just truncate and then fixate. We check for empty caps in the begin and a
fixate-func that empties a caps would be broken. It also helps lazy caps impl.
in bug 618853 by avoiding the gst_caps_get_size().
This commit is contained in:
Stefan Kost 2010-05-24 17:25:52 +03:00
parent 53c122df2b
commit 21b4ef4d0f

View file

@ -2416,13 +2416,16 @@ void
gst_pad_fixate_caps (GstPad * pad, GstCaps * caps) gst_pad_fixate_caps (GstPad * pad, GstCaps * caps)
{ {
GstPadFixateCapsFunction fixatefunc; GstPadFixateCapsFunction fixatefunc;
guint len; GstStructure *s;
g_return_if_fail (GST_IS_PAD (pad)); g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (caps != NULL); g_return_if_fail (caps != NULL);
g_return_if_fail (!gst_caps_is_empty (caps)); g_return_if_fail (!gst_caps_is_empty (caps));
/* FIXME-0.11: do not allow fixating any-caps
* g_return_if_fail (!gst_caps_is_any (caps));
*/
if (gst_caps_is_fixed (caps)) if (gst_caps_is_fixed (caps) || gst_caps_is_any (caps))
return; return;
fixatefunc = GST_PAD_FIXATECAPSFUNC (pad); fixatefunc = GST_PAD_FIXATECAPSFUNC (pad);
@ -2431,16 +2434,9 @@ gst_pad_fixate_caps (GstPad * pad, GstCaps * caps)
} }
/* default fixation */ /* default fixation */
len = gst_caps_get_size (caps); gst_caps_truncate (caps);
if (len > 0) { s = gst_caps_get_structure (caps, 0);
GstStructure *s = gst_caps_get_structure (caps, 0); gst_structure_foreach (s, gst_pad_default_fixate, s);
gst_structure_foreach (s, gst_pad_default_fixate, s);
}
if (len > 1) {
gst_caps_truncate (caps);
}
} }
/* Default accept caps implementation just checks against /* Default accept caps implementation just checks against