mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-28 23:02:22 +00:00
structure: add method to fixate one field
This commit is contained in:
parent
6b876ebf82
commit
b1573e9865
3 changed files with 39 additions and 12 deletions
|
@ -2683,6 +2683,42 @@ gst_structure_fixate_field_nearest_fraction (GstStructure * structure,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
default_fixate (GQuark field_id, const GValue * value, gpointer data)
|
||||
{
|
||||
GstStructure *s = data;
|
||||
GValue v = { 0 };
|
||||
|
||||
if (gst_value_fixate (&v, value)) {
|
||||
gst_structure_id_set_value (s, field_id, &v);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_structure_fixate_field:
|
||||
* @structure: a #GstStructure
|
||||
* @field_name: a field in @structure
|
||||
*
|
||||
* Fixates a #GstStructure by changing the given field with its fixated value.
|
||||
*
|
||||
* Returns: TRUE if the structure field could be fixated
|
||||
*/
|
||||
gboolean
|
||||
gst_structure_fixate_field (GstStructure * structure, const char *field_name)
|
||||
{
|
||||
GstStructureField *field;
|
||||
|
||||
g_return_val_if_fail (structure != NULL, FALSE);
|
||||
g_return_val_if_fail (IS_MUTABLE (structure), FALSE);
|
||||
|
||||
if (!(field = gst_structure_get_field (structure, field_name)))
|
||||
return FALSE;
|
||||
|
||||
return default_fixate (field->name, &field->value, structure);
|
||||
}
|
||||
|
||||
/* our very own version of G_VALUE_LCOPY that allows NULL return locations
|
||||
* (useful for message parsing functions where the return location is user
|
||||
* supplied and the user may pass NULL if the value isn't of interest) */
|
||||
|
@ -3192,18 +3228,6 @@ gst_structure_is_subset (const GstStructure * subset,
|
|||
gst_caps_structure_is_subset_field, (gpointer) superset);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
default_fixate (GQuark field_id, const GValue * value, gpointer data)
|
||||
{
|
||||
GstStructure *s = data;
|
||||
GValue v = { 0 };
|
||||
|
||||
if (gst_value_fixate (&v, value)) {
|
||||
gst_structure_id_set_value (s, field_id, &v);
|
||||
g_value_unset (&v);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_structure_fixate:
|
||||
|
|
|
@ -242,6 +242,8 @@ gboolean gst_structure_fixate_field_nearest_fraction (GstStructu
|
|||
const char *field_name,
|
||||
const gint target_numerator,
|
||||
const gint target_denominator);
|
||||
gboolean gst_structure_fixate_field (GstStructure *structure,
|
||||
const char *field_name);
|
||||
|
||||
gboolean gst_structure_is_equal(const GstStructure *structure1,
|
||||
const GstStructure *structure2);
|
||||
|
|
|
@ -970,6 +970,7 @@ EXPORTS
|
|||
gst_structure_copy
|
||||
gst_structure_empty_new
|
||||
gst_structure_fixate
|
||||
gst_structure_fixate_field
|
||||
gst_structure_fixate_field_boolean
|
||||
gst_structure_fixate_field_nearest_double
|
||||
gst_structure_fixate_field_nearest_fraction
|
||||
|
|
Loading…
Reference in a new issue