mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-02 05:28:48 +00:00
pad: use new gst_value_fixate instead
Use the new gst_value_fixate() function instead of our own version.
This commit is contained in:
parent
e2b6e88d5f
commit
d863976e59
1 changed files with 16 additions and 61 deletions
77
gst/gstpad.c
77
gst/gstpad.c
|
@ -2486,71 +2486,29 @@ no_peer:
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -2563,7 +2521,6 @@ void
|
|||
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);
|
||||
|
@ -2573,15 +2530,13 @@ gst_pad_fixate_caps (GstPad * pad, GstCaps * caps)
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue