From 78a44afc220294797ba2f7d9d80e044c84fa858b Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 23 May 2025 13:07:34 +0200 Subject: [PATCH] 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: --- girs/Gst-1.0.gir | 15 +++++++++++++++ subprojects/gstreamer/gst/gststructure.c | 20 ++++++++++++++++++++ subprojects/gstreamer/gst/gststructure.h | 3 +++ 3 files changed, 38 insertions(+) diff --git a/girs/Gst-1.0.gir b/girs/Gst-1.0.gir index 900c67dcb1..882c25c2ce 100644 --- a/girs/Gst-1.0.gir +++ b/girs/Gst-1.0.gir @@ -45557,6 +45557,21 @@ structure name and for all fields that are existing in @superset, + + Checks if the structure is writable. %TRUE if parent +is not set or its refcount is 1, %FALSE otherwise. + + + %TRUE if the structure is writable. + + + + + a #GstStructure + + + + 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 diff --git a/subprojects/gstreamer/gst/gststructure.c b/subprojects/gstreamer/gst/gststructure.c index c2f80b4302..bf8ef82e51 100644 --- a/subprojects/gstreamer/gst/gststructure.c +++ b/subprojects/gstreamer/gst/gststructure.c @@ -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); +} diff --git a/subprojects/gstreamer/gst/gststructure.h b/subprojects/gstreamer/gst/gststructure.h index dcad0eaa97..d85990f3dc 100644 --- a/subprojects/gstreamer/gst/gststructure.h +++ b/subprojects/gstreamer/gst/gststructure.h @@ -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