mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 13:41:48 +00:00
childproxy: use GstChildProxy instead of GObject on the public api
Fix usage and also cleanup gst_object api use on gobjects.
This commit is contained in:
parent
26682f7c7a
commit
19e5fc54b7
4 changed files with 48 additions and 45 deletions
|
@ -1162,7 +1162,8 @@ no_state_recalc:
|
||||||
elem_name);
|
elem_name);
|
||||||
|
|
||||||
g_signal_emit (bin, gst_bin_signals[ELEMENT_ADDED], 0, element);
|
g_signal_emit (bin, gst_bin_signals[ELEMENT_ADDED], 0, element);
|
||||||
gst_child_proxy_child_added ((GObject *) bin, (GObject *) element, elem_name);
|
gst_child_proxy_child_added ((GstChildProxy *) bin, (GObject *) element,
|
||||||
|
elem_name);
|
||||||
|
|
||||||
g_free (elem_name);
|
g_free (elem_name);
|
||||||
|
|
||||||
|
@ -1488,7 +1489,7 @@ no_state_recalc:
|
||||||
elem_name);
|
elem_name);
|
||||||
|
|
||||||
g_signal_emit (bin, gst_bin_signals[ELEMENT_REMOVED], 0, element);
|
g_signal_emit (bin, gst_bin_signals[ELEMENT_REMOVED], 0, element);
|
||||||
gst_child_proxy_child_removed ((GObject *) bin, (GObject *) element,
|
gst_child_proxy_child_removed ((GstChildProxy *) bin, (GObject *) element,
|
||||||
elem_name);
|
elem_name);
|
||||||
|
|
||||||
g_free (elem_name);
|
g_free (elem_name);
|
||||||
|
|
|
@ -188,7 +188,7 @@ gst_child_proxy_lookup (GObject * object, const gchar * name,
|
||||||
g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
|
g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
|
||||||
g_return_val_if_fail (name != NULL, FALSE);
|
g_return_val_if_fail (name != NULL, FALSE);
|
||||||
|
|
||||||
gst_object_ref (object);
|
g_object_ref (object);
|
||||||
|
|
||||||
current = names = g_strsplit (name, "::", -1);
|
current = names = g_strsplit (name, "::", -1);
|
||||||
while (current[1]) {
|
while (current[1]) {
|
||||||
|
@ -206,7 +206,7 @@ gst_child_proxy_lookup (GObject * object, const gchar * name,
|
||||||
GST_INFO ("no such object %s", current[0]);
|
GST_INFO ("no such object %s", current[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gst_object_unref (object);
|
g_object_unref (object);
|
||||||
object = next;
|
object = next;
|
||||||
current++;
|
current++;
|
||||||
}
|
}
|
||||||
|
@ -219,13 +219,13 @@ gst_child_proxy_lookup (GObject * object, const gchar * name,
|
||||||
if (pspec)
|
if (pspec)
|
||||||
*pspec = spec;
|
*pspec = spec;
|
||||||
if (target) {
|
if (target) {
|
||||||
gst_object_ref (object);
|
g_object_ref (object);
|
||||||
*target = object;
|
*target = object;
|
||||||
}
|
}
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gst_object_unref (object);
|
g_object_unref (object);
|
||||||
g_strfreev (names);
|
g_strfreev (names);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -240,21 +240,21 @@ gst_child_proxy_lookup (GObject * object, const gchar * name,
|
||||||
* You are responsible for freeing it by calling g_value_unset()
|
* You are responsible for freeing it by calling g_value_unset()
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_child_proxy_get_property (GObject * object, const gchar * name,
|
gst_child_proxy_get_property (GstChildProxy * object, const gchar * name,
|
||||||
GValue * value)
|
GValue * value)
|
||||||
{
|
{
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
GObject *target;
|
GObject *target;
|
||||||
|
|
||||||
g_return_if_fail (G_IS_OBJECT (object));
|
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
||||||
g_return_if_fail (name != NULL);
|
g_return_if_fail (name != NULL);
|
||||||
g_return_if_fail (G_IS_VALUE (value));
|
g_return_if_fail (G_IS_VALUE (value));
|
||||||
|
|
||||||
if (!gst_child_proxy_lookup (object, name, &target, &pspec))
|
if (!gst_child_proxy_lookup ((GObject *) object, name, &target, &pspec))
|
||||||
goto not_found;
|
goto not_found;
|
||||||
|
|
||||||
g_object_get_property (G_OBJECT (target), pspec->name, value);
|
g_object_get_property (target, pspec->name, value);
|
||||||
gst_object_unref (target);
|
g_object_unref (target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ not_found:
|
||||||
* Gets properties of the parent object and its children.
|
* Gets properties of the parent object and its children.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_child_proxy_get_valist (GObject * object,
|
gst_child_proxy_get_valist (GstChildProxy * object,
|
||||||
const gchar * first_property_name, va_list var_args)
|
const gchar * first_property_name, va_list var_args)
|
||||||
{
|
{
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
|
@ -284,18 +284,18 @@ gst_child_proxy_get_valist (GObject * object,
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
GObject *target;
|
GObject *target;
|
||||||
|
|
||||||
g_return_if_fail (G_IS_OBJECT (object));
|
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
||||||
|
|
||||||
name = first_property_name;
|
name = first_property_name;
|
||||||
|
|
||||||
/* iterate over pairs */
|
/* iterate over pairs */
|
||||||
while (name) {
|
while (name) {
|
||||||
if (!gst_child_proxy_lookup (object, name, &target, &pspec))
|
if (!gst_child_proxy_lookup ((GObject *) object, name, &target, &pspec))
|
||||||
goto not_found;
|
goto not_found;
|
||||||
|
|
||||||
g_value_init (&value, pspec->value_type);
|
g_value_init (&value, pspec->value_type);
|
||||||
g_object_get_property (G_OBJECT (target), pspec->name, &value);
|
g_object_get_property (target, pspec->name, &value);
|
||||||
gst_object_unref (target);
|
g_object_unref (target);
|
||||||
|
|
||||||
G_VALUE_LCOPY (&value, var_args, 0, &error);
|
G_VALUE_LCOPY (&value, var_args, 0, &error);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -329,11 +329,12 @@ cant_copy:
|
||||||
* Gets properties of the parent object and its children.
|
* Gets properties of the parent object and its children.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_child_proxy_get (GObject * object, const gchar * first_property_name, ...)
|
gst_child_proxy_get (GstChildProxy * object, const gchar * first_property_name,
|
||||||
|
...)
|
||||||
{
|
{
|
||||||
va_list var_args;
|
va_list var_args;
|
||||||
|
|
||||||
g_return_if_fail (G_IS_OBJECT (object));
|
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
||||||
|
|
||||||
va_start (var_args, first_property_name);
|
va_start (var_args, first_property_name);
|
||||||
gst_child_proxy_get_valist (object, first_property_name, var_args);
|
gst_child_proxy_get_valist (object, first_property_name, var_args);
|
||||||
|
@ -349,21 +350,21 @@ gst_child_proxy_get (GObject * object, const gchar * first_property_name, ...)
|
||||||
* Sets a single property using the GstChildProxy mechanism.
|
* Sets a single property using the GstChildProxy mechanism.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_child_proxy_set_property (GObject * object, const gchar * name,
|
gst_child_proxy_set_property (GstChildProxy * object, const gchar * name,
|
||||||
const GValue * value)
|
const GValue * value)
|
||||||
{
|
{
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
GObject *target;
|
GObject *target;
|
||||||
|
|
||||||
g_return_if_fail (G_IS_OBJECT (object));
|
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
||||||
g_return_if_fail (name != NULL);
|
g_return_if_fail (name != NULL);
|
||||||
g_return_if_fail (G_IS_VALUE (value));
|
g_return_if_fail (G_IS_VALUE (value));
|
||||||
|
|
||||||
if (!gst_child_proxy_lookup (object, name, &target, &pspec))
|
if (!gst_child_proxy_lookup ((GObject *) object, name, &target, &pspec))
|
||||||
goto not_found;
|
goto not_found;
|
||||||
|
|
||||||
g_object_set_property (G_OBJECT (target), pspec->name, value);
|
g_object_set_property (target, pspec->name, value);
|
||||||
gst_object_unref (target);
|
g_object_unref (target);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
not_found:
|
not_found:
|
||||||
|
@ -383,7 +384,7 @@ not_found:
|
||||||
* Sets properties of the parent object and its children.
|
* Sets properties of the parent object and its children.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_child_proxy_set_valist (GObject * object,
|
gst_child_proxy_set_valist (GstChildProxy * object,
|
||||||
const gchar * first_property_name, va_list var_args)
|
const gchar * first_property_name, va_list var_args)
|
||||||
{
|
{
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
|
@ -392,13 +393,13 @@ gst_child_proxy_set_valist (GObject * object,
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
GObject *target;
|
GObject *target;
|
||||||
|
|
||||||
g_return_if_fail (G_IS_OBJECT (object));
|
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
||||||
|
|
||||||
name = first_property_name;
|
name = first_property_name;
|
||||||
|
|
||||||
/* iterate over pairs */
|
/* iterate over pairs */
|
||||||
while (name) {
|
while (name) {
|
||||||
if (!gst_child_proxy_lookup (object, name, &target, &pspec))
|
if (!gst_child_proxy_lookup ((GObject *) object, name, &target, &pspec))
|
||||||
goto not_found;
|
goto not_found;
|
||||||
|
|
||||||
G_VALUE_COLLECT_INIT (&value, pspec->value_type, var_args,
|
G_VALUE_COLLECT_INIT (&value, pspec->value_type, var_args,
|
||||||
|
@ -407,8 +408,8 @@ gst_child_proxy_set_valist (GObject * object,
|
||||||
if (error)
|
if (error)
|
||||||
goto cant_copy;
|
goto cant_copy;
|
||||||
|
|
||||||
g_object_set_property (G_OBJECT (target), pspec->name, &value);
|
g_object_set_property (target, pspec->name, &value);
|
||||||
gst_object_unref (target);
|
g_object_unref (target);
|
||||||
|
|
||||||
g_value_unset (&value);
|
g_value_unset (&value);
|
||||||
name = va_arg (var_args, gchar *);
|
name = va_arg (var_args, gchar *);
|
||||||
|
@ -426,7 +427,7 @@ cant_copy:
|
||||||
g_warning ("error copying value %s in object %s: %s", pspec->name,
|
g_warning ("error copying value %s in object %s: %s", pspec->name,
|
||||||
(GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""), error);
|
(GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""), error);
|
||||||
g_value_unset (&value);
|
g_value_unset (&value);
|
||||||
gst_object_unref (target);
|
g_object_unref (target);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -440,11 +441,12 @@ cant_copy:
|
||||||
* Sets properties of the parent object and its children.
|
* Sets properties of the parent object and its children.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_child_proxy_set (GObject * object, const gchar * first_property_name, ...)
|
gst_child_proxy_set (GstChildProxy * object, const gchar * first_property_name,
|
||||||
|
...)
|
||||||
{
|
{
|
||||||
va_list var_args;
|
va_list var_args;
|
||||||
|
|
||||||
g_return_if_fail (G_IS_OBJECT (object));
|
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
||||||
|
|
||||||
va_start (var_args, first_property_name);
|
va_start (var_args, first_property_name);
|
||||||
gst_child_proxy_set_valist (object, first_property_name, var_args);
|
gst_child_proxy_set_valist (object, first_property_name, var_args);
|
||||||
|
@ -460,10 +462,10 @@ gst_child_proxy_set (GObject * object, const gchar * first_property_name, ...)
|
||||||
* Emits the "child-added" signal.
|
* Emits the "child-added" signal.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_child_proxy_child_added (GObject * object, GObject * child,
|
gst_child_proxy_child_added (GstChildProxy * object, GObject * child,
|
||||||
const gchar * name)
|
const gchar * name)
|
||||||
{
|
{
|
||||||
g_signal_emit (G_OBJECT (object), signals[CHILD_ADDED], 0, child, name);
|
g_signal_emit (object, signals[CHILD_ADDED], 0, child, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -475,10 +477,10 @@ gst_child_proxy_child_added (GObject * object, GObject * child,
|
||||||
* Emits the "child-removed" signal.
|
* Emits the "child-removed" signal.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_child_proxy_child_removed (GObject * object, GObject * child,
|
gst_child_proxy_child_removed (GstChildProxy * object, GObject * child,
|
||||||
const gchar * name)
|
const gchar * name)
|
||||||
{
|
{
|
||||||
g_signal_emit (G_OBJECT (object), signals[CHILD_REMOVED], 0, child, name);
|
g_signal_emit (object, signals[CHILD_REMOVED], 0, child, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* gobject methods */
|
/* gobject methods */
|
||||||
|
|
|
@ -77,27 +77,27 @@ GObject * gst_child_proxy_get_child_by_index (GstChildProxy * parent, guint inde
|
||||||
gboolean gst_child_proxy_lookup (GObject *object, const gchar *name,
|
gboolean gst_child_proxy_lookup (GObject *object, const gchar *name,
|
||||||
GObject **target, GParamSpec **pspec);
|
GObject **target, GParamSpec **pspec);
|
||||||
|
|
||||||
void gst_child_proxy_get_property (GObject * object, const gchar *name,
|
void gst_child_proxy_get_property (GstChildProxy * object, const gchar *name,
|
||||||
GValue *value);
|
GValue *value);
|
||||||
void gst_child_proxy_get_valist (GObject * object,
|
void gst_child_proxy_get_valist (GstChildProxy * object,
|
||||||
const gchar * first_property_name,
|
const gchar * first_property_name,
|
||||||
va_list var_args);
|
va_list var_args);
|
||||||
void gst_child_proxy_get (GObject * object,
|
void gst_child_proxy_get (GstChildProxy * object,
|
||||||
const gchar * first_property_name,
|
const gchar * first_property_name,
|
||||||
...) G_GNUC_NULL_TERMINATED;
|
...) G_GNUC_NULL_TERMINATED;
|
||||||
|
|
||||||
void gst_child_proxy_set_property (GObject * object, const gchar *name,
|
void gst_child_proxy_set_property (GstChildProxy * object, const gchar *name,
|
||||||
const GValue *value);
|
const GValue *value);
|
||||||
void gst_child_proxy_set_valist (GObject* object,
|
void gst_child_proxy_set_valist (GstChildProxy* object,
|
||||||
const gchar * first_property_name,
|
const gchar * first_property_name,
|
||||||
va_list var_args);
|
va_list var_args);
|
||||||
void gst_child_proxy_set (GObject * object,
|
void gst_child_proxy_set (GstChildProxy * object,
|
||||||
const gchar * first_property_name,
|
const gchar * first_property_name,
|
||||||
...) G_GNUC_NULL_TERMINATED;
|
...) G_GNUC_NULL_TERMINATED;
|
||||||
|
|
||||||
void gst_child_proxy_child_added (GObject * object, GObject * child,
|
void gst_child_proxy_child_added (GstChildProxy * object, GObject * child,
|
||||||
const gchar *name);
|
const gchar *name);
|
||||||
void gst_child_proxy_child_removed (GObject * object, GObject * child,
|
void gst_child_proxy_child_removed (GstChildProxy * object, GObject * child,
|
||||||
const gchar *name);
|
const gchar *name);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -29,7 +29,7 @@ GST_START_TEST (test_get)
|
||||||
pipeline = gst_pipeline_new ("foo");
|
pipeline = gst_pipeline_new ("foo");
|
||||||
fail_unless (pipeline != NULL, "Could not create pipeline");
|
fail_unless (pipeline != NULL, "Could not create pipeline");
|
||||||
|
|
||||||
gst_child_proxy_get (G_OBJECT (pipeline), "name", &name, NULL);
|
gst_child_proxy_get (GST_CHILD_PROXY (pipeline), "name", &name, NULL);
|
||||||
fail_if (g_strcmp0 ("foo", name));
|
fail_if (g_strcmp0 ("foo", name));
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ GST_START_TEST (test_child_get)
|
||||||
|
|
||||||
gst_bin_add (GST_BIN (pipeline), elem);
|
gst_bin_add (GST_BIN (pipeline), elem);
|
||||||
|
|
||||||
gst_child_proxy_get (G_OBJECT (pipeline), "src::name", &name, NULL);
|
gst_child_proxy_get (GST_CHILD_PROXY (pipeline), "src::name", &name, NULL);
|
||||||
fail_if (g_strcmp0 ("src", name));
|
fail_if (g_strcmp0 ("src", name));
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue