}
static gboolean
-fixate_value (GValue * dest, const GValue * src)
-{
- if (G_VALUE_TYPE (src) == GST_TYPE_INT_RANGE) {
- g_value_init (dest, G_TYPE_INT);
- g_value_set_int (dest, gst_value_get_int_range_min (src));
- } else if (G_VALUE_TYPE (src) == GST_TYPE_DOUBLE_RANGE) {
- g_value_init (dest, G_TYPE_DOUBLE);
- g_value_set_double (dest, gst_value_get_double_range_min (src));
- } else if (G_VALUE_TYPE (src) == GST_TYPE_FRACTION_RANGE) {
- gst_value_init_and_copy (dest, gst_value_get_fraction_range_min (src));
- } else if (G_VALUE_TYPE (src) == GST_TYPE_LIST) {
- GValue temp = { 0 };
-
- /* list could be empty */
- if (gst_value_list_get_size (src) <= 0)
- return FALSE;
-
- gst_value_init_and_copy (&temp, gst_value_list_get_value (src, 0));
-
- if (!fixate_value (dest, &temp))
- gst_value_init_and_copy (dest, &temp);
- g_value_unset (&temp);
- } else if (G_VALUE_TYPE (src) == GST_TYPE_ARRAY) {
- gboolean res = FALSE;
- guint n, len;
-
- len = gst_value_array_get_size (src);
- g_value_init (dest, GST_TYPE_ARRAY);
- for (n = 0; n < len; n++) {
- GValue kid = { 0 };
- const GValue *orig_kid = gst_value_array_get_value (src, n);
-
- if (!fixate_value (&kid, orig_kid))
- gst_value_init_and_copy (&kid, orig_kid);
- else
- res = TRUE;
- gst_value_array_append_value (dest, &kid);
- g_value_unset (&kid);
- }
-
- if (!res)
- g_value_unset (dest);
-
- return res;
- } else {
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-gst_pad_default_fixate (GQuark field_id, const GValue * value, gpointer data)
+default_fixate (GQuark field_id, const GValue * value, gpointer data)
{
GstStructure *s = data;
GValue v = { 0 };
- if (fixate_value (&v, value)) {
+ if (gst_value_fixate (&v, value)) {
gst_structure_id_set_value (s, field_id, &v);
g_value_unset (&v);
}
-
return TRUE;
}
+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_foreach (s, default_fixate, s);
+}
+
/**
* gst_pad_fixate_caps:
* @pad: a #GstPad to fixate
gst_pad_fixate_caps (GstPad * pad, GstCaps * caps)
{
GstPadFixateCapsFunction fixatefunc;
- GstStructure *s;
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (caps != NULL);
if (gst_caps_is_fixed (caps) || gst_caps_is_any (caps))
return;
+ g_return_if_fail (gst_caps_is_writable (caps));
+
fixatefunc = GST_PAD_FIXATECAPSFUNC (pad);
if (fixatefunc) {
fixatefunc (pad, caps);
}
-
- /* default fixation */
- gst_caps_truncate (caps);
- s = gst_caps_get_structure (caps, 0);
- gst_structure_foreach (s, gst_pad_default_fixate, s);
+ gst_pad_default_fixate (pad, caps);
}
/* Default accept caps implementation just checks against