diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 6bf86cdb78..53d974a334 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -1776,6 +1776,28 @@ gst_caps_do_simplify (GstCaps * caps) return TRUE; } +/** + * gst_caps_fixate: + * @caps: a #GstCaps to fixate + * + * Modifies the given @caps inplace into a representation with only fixed + * values. First the caps will be truncated and then the first structure will be + * fixated with gst_structure_fixate(). @caps should be writable. + */ +void +gst_caps_fixate (GstCaps * caps) +{ + GstStructure *s; + + g_return_if_fail (GST_IS_CAPS (caps)); + g_return_if_fail (IS_WRITABLE (caps)); + + /* default fixation */ + gst_caps_truncate (caps); + s = gst_caps_get_structure (caps, 0); + gst_structure_fixate (s); +} + /* utility */ /** diff --git a/gst/gstcaps.h b/gst/gstcaps.h index bd8f8f88c9..b5c8a3e0b7 100644 --- a/gst/gstcaps.h +++ b/gst/gstcaps.h @@ -406,6 +406,8 @@ GstCaps * gst_caps_union (const GstCaps *caps1, GstCaps * gst_caps_normalize (const GstCaps *caps); gboolean gst_caps_do_simplify (GstCaps *caps); +void gst_caps_fixate (GstCaps *caps); + /* utility */ gchar * gst_caps_to_string (const GstCaps *caps); GstCaps * gst_caps_from_string (const gchar *string); diff --git a/gst/gstpad.c b/gst/gstpad.c index 4cfcea85e4..e08e3960a3 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2491,12 +2491,8 @@ no_peer: static void gst_pad_default_fixate (GstPad * pad, GstCaps * caps) { - GstStructure *s; - /* default fixation */ - gst_caps_truncate (caps); - s = gst_caps_get_structure (caps, 0); - gst_structure_fixate (s); + gst_caps_fixate (caps); } /** diff --git a/gst/gststructure.c b/gst/gststructure.c index b04236ea7d..34cf80627c 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -3215,5 +3215,7 @@ default_fixate (GQuark field_id, const GValue * value, gpointer data) void gst_structure_fixate (GstStructure * structure) { + g_return_if_fail (GST_IS_STRUCTURE (structure)); + gst_structure_foreach (structure, default_fixate, structure); }