mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 13:41:48 +00:00
structure: add gst_structure_{id_}take_value()
Add _set_value() variants that take ownership of the value passed instead of making a copy of the value. This is useful for setting values to things that aren't refcounted (e.g. GValueArrays or strings or string arrays, etc.). API: gst_structure_take_value() API: gst_structure_id_take_value() https://bugzilla.gnome.org/show_bug.cgi?id=629831
This commit is contained in:
parent
e6a291bfab
commit
7e5a9580ef
4 changed files with 77 additions and 0 deletions
|
@ -2097,10 +2097,12 @@ gst_structure_id_get
|
||||||
gst_structure_id_get_valist
|
gst_structure_id_get_valist
|
||||||
gst_structure_id_get_value
|
gst_structure_id_get_value
|
||||||
gst_structure_id_set_value
|
gst_structure_id_set_value
|
||||||
|
gst_structure_id_take_value
|
||||||
gst_structure_get
|
gst_structure_get
|
||||||
gst_structure_get_valist
|
gst_structure_get_valist
|
||||||
gst_structure_get_value
|
gst_structure_get_value
|
||||||
gst_structure_set_value
|
gst_structure_set_value
|
||||||
|
gst_structure_take_value
|
||||||
gst_structure_set
|
gst_structure_set
|
||||||
gst_structure_set_valist
|
gst_structure_set_valist
|
||||||
gst_structure_id_set
|
gst_structure_id_set
|
||||||
|
|
|
@ -466,6 +466,73 @@ gst_structure_set_value (GstStructure * structure,
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
gst_structure_id_take_value_internal (GstStructure * structure, GQuark field,
|
||||||
|
GValue * value)
|
||||||
|
{
|
||||||
|
GstStructureField gsfield = { 0, {0,} };
|
||||||
|
|
||||||
|
gsfield.name = field;
|
||||||
|
gsfield.value = *value;
|
||||||
|
|
||||||
|
gst_structure_set_field (structure, &gsfield);
|
||||||
|
|
||||||
|
/* we took ownership */
|
||||||
|
#ifdef USE_POISONING
|
||||||
|
memset (value, 0, sizeof (GValue));
|
||||||
|
#else
|
||||||
|
value->g_type = G_TYPE_INVALID;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_structure_id_take_value:
|
||||||
|
* @structure: a #GstStructure
|
||||||
|
* @field: a #GQuark representing a field
|
||||||
|
* @value: (transfer full): the new value of the field
|
||||||
|
*
|
||||||
|
* Sets the field with the given GQuark @field to @value. If the field
|
||||||
|
* does not exist, it is created. If the field exists, the previous
|
||||||
|
* value is replaced and freed.
|
||||||
|
*
|
||||||
|
* Since: 0.10.31
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_structure_id_take_value (GstStructure * structure, GQuark field,
|
||||||
|
GValue * value)
|
||||||
|
{
|
||||||
|
g_return_if_fail (structure != NULL);
|
||||||
|
g_return_if_fail (G_IS_VALUE (value));
|
||||||
|
g_return_if_fail (IS_MUTABLE (structure));
|
||||||
|
|
||||||
|
gst_structure_id_take_value_internal (structure, field, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_structure_take_value:
|
||||||
|
* @structure: a #GstStructure
|
||||||
|
* @fieldname: the name of the field to set
|
||||||
|
* @value: (transfer full): the new value of the field
|
||||||
|
*
|
||||||
|
* Sets the field with the given name @field to @value. If the field
|
||||||
|
* does not exist, it is created. If the field exists, the previous
|
||||||
|
* value is replaced and freed. The function will take ownership of @value.
|
||||||
|
*
|
||||||
|
* Since: 0.10.31
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_structure_take_value (GstStructure * structure, const gchar * fieldname,
|
||||||
|
GValue * value)
|
||||||
|
{
|
||||||
|
g_return_if_fail (structure != NULL);
|
||||||
|
g_return_if_fail (fieldname != NULL);
|
||||||
|
g_return_if_fail (G_IS_VALUE (value));
|
||||||
|
g_return_if_fail (IS_MUTABLE (structure));
|
||||||
|
|
||||||
|
gst_structure_id_take_value_internal (structure,
|
||||||
|
g_quark_from_string (fieldname), value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_structure_set:
|
* gst_structure_set:
|
||||||
* @structure: a #GstStructure
|
* @structure: a #GstStructure
|
||||||
|
|
|
@ -117,6 +117,12 @@ void gst_structure_id_set_value (GstStructure
|
||||||
void gst_structure_set_value (GstStructure *structure,
|
void gst_structure_set_value (GstStructure *structure,
|
||||||
const gchar *fieldname,
|
const gchar *fieldname,
|
||||||
const GValue *value);
|
const GValue *value);
|
||||||
|
void gst_structure_id_take_value (GstStructure *structure,
|
||||||
|
GQuark field,
|
||||||
|
GValue *value);
|
||||||
|
void gst_structure_take_value (GstStructure *structure,
|
||||||
|
const gchar *fieldname,
|
||||||
|
GValue *value);
|
||||||
void gst_structure_set (GstStructure *structure,
|
void gst_structure_set (GstStructure *structure,
|
||||||
const gchar *fieldname,
|
const gchar *fieldname,
|
||||||
...) G_GNUC_NULL_TERMINATED;
|
...) G_GNUC_NULL_TERMINATED;
|
||||||
|
|
|
@ -954,6 +954,7 @@ EXPORTS
|
||||||
gst_structure_id_set
|
gst_structure_id_set
|
||||||
gst_structure_id_set_valist
|
gst_structure_id_set_valist
|
||||||
gst_structure_id_set_value
|
gst_structure_id_set_value
|
||||||
|
gst_structure_id_take_value
|
||||||
gst_structure_map_in_place
|
gst_structure_map_in_place
|
||||||
gst_structure_n_fields
|
gst_structure_n_fields
|
||||||
gst_structure_new
|
gst_structure_new
|
||||||
|
@ -968,6 +969,7 @@ EXPORTS
|
||||||
gst_structure_set_parent_refcount
|
gst_structure_set_parent_refcount
|
||||||
gst_structure_set_valist
|
gst_structure_set_valist
|
||||||
gst_structure_set_value
|
gst_structure_set_value
|
||||||
|
gst_structure_take_value
|
||||||
gst_structure_to_string
|
gst_structure_to_string
|
||||||
gst_system_clock_get_type
|
gst_system_clock_get_type
|
||||||
gst_system_clock_obtain
|
gst_system_clock_obtain
|
||||||
|
|
Loading…
Reference in a new issue