diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 2f08eed190..75acea5037 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -2097,10 +2097,12 @@ gst_structure_id_get gst_structure_id_get_valist gst_structure_id_get_value gst_structure_id_set_value +gst_structure_id_take_value gst_structure_get gst_structure_get_valist gst_structure_get_value gst_structure_set_value +gst_structure_take_value gst_structure_set gst_structure_set_valist gst_structure_id_set diff --git a/gst/gststructure.c b/gst/gststructure.c index 12fc954965..daf52b8d03 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -466,6 +466,73 @@ gst_structure_set_value (GstStructure * structure, 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: * @structure: a #GstStructure diff --git a/gst/gststructure.h b/gst/gststructure.h index 98f197ba2d..48c81c4596 100644 --- a/gst/gststructure.h +++ b/gst/gststructure.h @@ -117,6 +117,12 @@ void gst_structure_id_set_value (GstStructure void gst_structure_set_value (GstStructure *structure, const gchar *fieldname, 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, const gchar *fieldname, ...) G_GNUC_NULL_TERMINATED; diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index ba11cd74c3..226d189e7f 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -954,6 +954,7 @@ EXPORTS gst_structure_id_set gst_structure_id_set_valist gst_structure_id_set_value + gst_structure_id_take_value gst_structure_map_in_place gst_structure_n_fields gst_structure_new @@ -968,6 +969,7 @@ EXPORTS gst_structure_set_parent_refcount gst_structure_set_valist gst_structure_set_value + gst_structure_take_value gst_structure_to_string gst_system_clock_get_type gst_system_clock_obtain