diff options
-rw-r--r-- | docs/gst/gstreamer-sections.txt | 2 | ||||
-rw-r--r-- | gst/gstutils.c | 73 | ||||
-rw-r--r-- | gst/gstutils.h | 4 | ||||
-rw-r--r-- | win32/common/libgstreamer.def | 2 |
4 files changed, 81 insertions, 0 deletions
diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 5acc42d9b..18f106fb7 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -3546,6 +3546,8 @@ gst_util_seqnum_compare gst_util_group_id_next gst_util_set_object_arg gst_util_set_value_from_string +gst_util_set_object_array +gst_util_get_object_array gst_util_get_timestamp GstSearchMode gst_util_array_binary_search diff --git a/gst/gstutils.c b/gst/gstutils.c index 31a23c8bf..ec3a33579 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -30,6 +30,10 @@ * */ +/* FIXME 2.0: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include "gst_private.h" #include <stdio.h> #include <string.h> @@ -167,6 +171,75 @@ done: g_value_unset (&v); } +/** + * gst_util_set_object_array: + * @object: the object to set the array to + * @name: the name of the property to set + * @array: a #GValueArray containing the values + * + * Transfer a #GValueArray to %GST_TYPE_ARRAY and set this value on the + * specified property name. This allow language bindings to set GST_TYPE_ARRAY + * properties which are otherwise not an accessible type. + * + * Since: 1.12 + */ +gboolean +gst_util_set_object_array (GObject * object, const gchar * name, + const GValueArray * array) +{ + GValue v1 = G_VALUE_INIT, v2 = G_VALUE_INIT; + gboolean ret = FALSE; + + g_value_init (&v1, G_TYPE_VALUE_ARRAY); + g_value_init (&v2, GST_TYPE_ARRAY); + + g_value_set_static_boxed (&v1, array); + + if (g_value_transform (&v1, &v2)) { + g_object_set_property (object, name, &v2); + ret = TRUE; + } + + g_value_unset (&v1); + g_value_unset (&v2); + + return ret; +} + +/** + * gst_util_get_object_array: + * @object: the object to set the array to + * @name: the name of the property to set + * @array: (out): a return #GValueArray + * + * Get a property of type %GST_TYPE_ARRAY and transform it into a + * #GValueArray. This allow language bindings to get GST_TYPE_ARRAY + * properties which are otherwise not an accessible type. + * + * Since: 1.12 + */ +gboolean +gst_util_get_object_array (GObject * object, const gchar * name, + GValueArray ** array) +{ + GValue v1 = G_VALUE_INIT, v2 = G_VALUE_INIT; + gboolean ret = FALSE; + + g_value_init (&v1, G_TYPE_VALUE_ARRAY); + g_value_init (&v2, GST_TYPE_ARRAY); + + g_object_get_property (object, name, &v2); + + if (g_value_transform (&v2, &v1)) { + *array = g_value_get_boxed (&v1); + ret = TRUE; + } + + g_value_unset (&v2); + + return ret; +} + /* work around error C2520: conversion from unsigned __int64 to double * not implemented, use signed __int64 * diff --git a/gst/gstutils.h b/gst/gstutils.h index e3ab89005..b56ad093c 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -34,6 +34,10 @@ G_BEGIN_DECLS void gst_util_set_value_from_string (GValue *value, const gchar *value_str); void gst_util_set_object_arg (GObject *object, const gchar *name, const gchar *value); +gboolean gst_util_set_object_array (GObject * object, const gchar * name, + const GValueArray * array); +gboolean gst_util_get_object_array (GObject * object, const gchar * name, + GValueArray ** array); void gst_util_dump_mem (const guchar *mem, guint size); guint64 gst_util_gdouble_to_guint64 (gdouble value) G_GNUC_CONST; diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index 99a154145..3b2aeccb8 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -1563,6 +1563,8 @@ EXPORTS gst_util_seqnum_compare gst_util_seqnum_next gst_util_set_object_arg + gst_util_set_object_array + gst_util_get_object_array gst_util_set_value_from_string gst_util_uint64_scale gst_util_uint64_scale_ceil |