mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-08 07:22:32 +00:00
gstutils: Add helpers to get/set array properties
This is to help bindings access properties of type GST_TYPE_ARRAY. This function will get/set the property and convert form/to GValueArray. New API: gst_util_set_object_array gst_util_get_object_array https://bugzilla.gnome.org/show_bug.cgi?id=753754
This commit is contained in:
parent
c21e219ed4
commit
2c056563bf
4 changed files with 81 additions and 0 deletions
|
@ -3546,6 +3546,8 @@ gst_util_seqnum_compare
|
||||||
gst_util_group_id_next
|
gst_util_group_id_next
|
||||||
gst_util_set_object_arg
|
gst_util_set_object_arg
|
||||||
gst_util_set_value_from_string
|
gst_util_set_value_from_string
|
||||||
|
gst_util_set_object_array
|
||||||
|
gst_util_get_object_array
|
||||||
gst_util_get_timestamp
|
gst_util_get_timestamp
|
||||||
GstSearchMode
|
GstSearchMode
|
||||||
gst_util_array_binary_search
|
gst_util_array_binary_search
|
||||||
|
|
|
@ -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 "gst_private.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -167,6 +171,75 @@ done:
|
||||||
g_value_unset (&v);
|
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
|
/* work around error C2520: conversion from unsigned __int64 to double
|
||||||
* not implemented, use signed __int64
|
* not implemented, use signed __int64
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,6 +34,10 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
void gst_util_set_value_from_string (GValue *value, const gchar *value_str);
|
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);
|
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);
|
void gst_util_dump_mem (const guchar *mem, guint size);
|
||||||
|
|
||||||
guint64 gst_util_gdouble_to_guint64 (gdouble value) G_GNUC_CONST;
|
guint64 gst_util_gdouble_to_guint64 (gdouble value) G_GNUC_CONST;
|
||||||
|
|
|
@ -1563,6 +1563,8 @@ EXPORTS
|
||||||
gst_util_seqnum_compare
|
gst_util_seqnum_compare
|
||||||
gst_util_seqnum_next
|
gst_util_seqnum_next
|
||||||
gst_util_set_object_arg
|
gst_util_set_object_arg
|
||||||
|
gst_util_set_object_array
|
||||||
|
gst_util_get_object_array
|
||||||
gst_util_set_value_from_string
|
gst_util_set_value_from_string
|
||||||
gst_util_uint64_scale
|
gst_util_uint64_scale
|
||||||
gst_util_uint64_scale_ceil
|
gst_util_uint64_scale_ceil
|
||||||
|
|
Loading…
Reference in a new issue