gst: Add a gst_structure_is_writable method

There are cases (in the gst-python bindings for example) where
it is interesting to know that the structure is not writable

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9027>
This commit is contained in:
Thibault Saunier 2025-05-23 13:07:34 +02:00
parent f0e1591111
commit 78a44afc22
3 changed files with 38 additions and 0 deletions

View File

@ -45557,6 +45557,21 @@ structure name and for all fields that are existing in @superset,
</parameter>
</parameters>
</method>
<method name="is_writable" c:identifier="gst_structure_is_writable" version="1.28">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gststructure.c">Checks if the structure is writable. %TRUE if parent
is not set or its refcount is 1, %FALSE otherwise.</doc>
<source-position filename="../subprojects/gstreamer/gst/gststructure.h"/>
<return-value transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gststructure.c">%TRUE if the structure is writable.</doc>
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<instance-parameter name="structure" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gststructure.c">a #GstStructure</doc>
<type name="Structure" c:type="const GstStructure*"/>
</instance-parameter>
</parameters>
</method>
<method name="map_in_place" c:identifier="gst_structure_map_in_place" deprecated="1" deprecated-version="1.26">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gststructure.c">Calls the provided function once for each field in the #GstStructure. In
contrast to gst_structure_foreach(), the function may modify but not delete the

View File

@ -4684,3 +4684,23 @@ gst_structure_get_flags (const GstStructure * structure,
return TRUE;
}
/**
* gst_structure_is_writable:
* @structure: a #GstStructure
*
* Checks if the structure is writable. %TRUE if parent
* is not set or its refcount is 1, %FALSE otherwise.
*
* Returns: %TRUE if the structure is writable.
*
* Since: 1.28
*/
gboolean
gst_structure_is_writable (const GstStructure * structure)
{
g_return_val_if_fail (GST_IS_STRUCTURE (structure), FALSE);
return IS_MUTABLE (structure);
}

View File

@ -582,6 +582,9 @@ GST_API
GstStructure * gst_structure_intersect (const GstStructure * struct1,
const GstStructure * struct2) G_GNUC_MALLOC;
GST_API
gboolean gst_structure_is_writable (const GstStructure * structure);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstStructure, gst_structure_free)
G_END_DECLS