caps: add fixate function

Add a fixate function and use it in gstpad.c
This commit is contained in:
Wim Taymans 2011-08-15 14:40:38 +02:00
parent bd20d2d199
commit 49fc4249e5
4 changed files with 27 additions and 5 deletions

View file

@ -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 */
/**

View file

@ -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);

View file

@ -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);
}
/**

View file

@ -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);
}