|
Packit Service |
963350 |
/* GStreamer
|
|
Packit Service |
963350 |
* Copyright (C) 2005 Stefan Kost <ensonic@users.sf.net>
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* gstchildproxy.c: interface for multi child elements
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
963350 |
* modify it under the terms of the GNU Library General Public
|
|
Packit Service |
963350 |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
963350 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
963350 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
963350 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
963350 |
* Library General Public License for more details.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* You should have received a copy of the GNU Library General Public
|
|
Packit Service |
963350 |
* License along with this library; if not, write to the
|
|
Packit Service |
963350 |
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
Packit Service |
963350 |
* Boston, MA 02110-1301, USA.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* SECTION:gstchildproxy
|
|
Packit Service |
963350 |
* @title: GstChildProxy
|
|
Packit Service |
963350 |
* @short_description: Interface for multi child elements.
|
|
Packit Service |
963350 |
* @see_also: #GstBin
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* This interface abstracts handling of property sets for elements with
|
|
Packit Service |
963350 |
* children. Imagine elements such as mixers or polyphonic generators. They all
|
|
Packit Service |
963350 |
* have multiple #GstPad or some kind of voice objects. Another use case are
|
|
Packit Service |
963350 |
* container elements like #GstBin.
|
|
Packit Service |
963350 |
* The element implementing the interface acts as a parent for those child
|
|
Packit Service |
963350 |
* objects.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* By implementing this interface the child properties can be accessed from the
|
|
Packit Service |
963350 |
* parent element by using gst_child_proxy_get() and gst_child_proxy_set().
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Property names are written as "child-name::property-name". The whole naming
|
|
Packit Service |
963350 |
* scheme is recursive. Thus "child1::child2::property" is valid too, if
|
|
Packit Service |
963350 |
* "child1" and "child2" implement the #GstChildProxy interface.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
#include "gst_private.h"
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
#include "gstchildproxy.h"
|
|
Packit Service |
963350 |
#include <gobject/gvaluecollector.h>
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/* signals */
|
|
Packit Service |
963350 |
enum
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
CHILD_ADDED,
|
|
Packit Service |
963350 |
CHILD_REMOVED,
|
|
Packit Service |
963350 |
LAST_SIGNAL
|
|
Packit Service |
963350 |
};
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
static guint signals[LAST_SIGNAL] = { 0 };
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
static GObject *
|
|
Packit Service |
963350 |
gst_child_proxy_default_get_child_by_name (GstChildProxy * parent,
|
|
Packit Service |
963350 |
const gchar * name)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
guint count, i;
|
|
Packit Service |
963350 |
GObject *object, *result;
|
|
Packit Service |
963350 |
gchar *object_name;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), NULL);
|
|
Packit Service |
963350 |
g_return_val_if_fail (name != NULL, NULL);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
result = NULL;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
count = gst_child_proxy_get_children_count (parent);
|
|
Packit Service |
963350 |
for (i = 0; i < count; i++) {
|
|
Packit Service |
963350 |
gboolean eq;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (!(object = gst_child_proxy_get_child_by_index (parent, i)))
|
|
Packit Service |
963350 |
continue;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (!GST_IS_OBJECT (object)) {
|
|
Packit Service |
963350 |
goto next;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
object_name = gst_object_get_name (GST_OBJECT_CAST (object));
|
|
Packit Service |
963350 |
if (object_name == NULL) {
|
|
Packit Service |
963350 |
g_warning ("child %u of parent %s has no name", i,
|
|
Packit Service |
963350 |
GST_OBJECT_NAME (parent));
|
|
Packit Service |
963350 |
goto next;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
eq = g_str_equal (object_name, name);
|
|
Packit Service |
963350 |
g_free (object_name);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (eq) {
|
|
Packit Service |
963350 |
result = object;
|
|
Packit Service |
963350 |
break;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
next:
|
|
Packit Service |
963350 |
g_object_unref (object);
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
return result;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_get_child_by_name:
|
|
Packit Service |
963350 |
* @parent: the parent object to get the child from
|
|
Packit Service |
963350 |
* @name: the child's name
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Looks up a child element by the given name.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* This virtual method has a default implementation that uses #GstObject
|
|
Packit Service |
963350 |
* together with gst_object_get_name(). If the interface is to be used with
|
|
Packit Service |
963350 |
* #GObjects, this methods needs to be overridden.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Returns: (transfer full) (nullable): the child object or %NULL if
|
|
Packit Service |
963350 |
* not found. Unref after usage.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* MT safe.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
GObject *
|
|
Packit Service |
963350 |
gst_child_proxy_get_child_by_name (GstChildProxy * parent, const gchar * name)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
GstChildProxyInterface *iface;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), 0);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
iface = GST_CHILD_PROXY_GET_INTERFACE (parent);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (iface->get_child_by_name != NULL)
|
|
Packit Service |
963350 |
return iface->get_child_by_name (parent, name);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
return NULL;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_get_child_by_index:
|
|
Packit Service |
963350 |
* @parent: the parent object to get the child from
|
|
Packit Service |
963350 |
* @index: the child's position in the child list
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Fetches a child by its number.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Returns: (transfer full) (nullable): the child object or %NULL if
|
|
Packit Service |
963350 |
* not found (index too high). Unref after usage.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* MT safe.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
GObject *
|
|
Packit Service |
963350 |
gst_child_proxy_get_child_by_index (GstChildProxy * parent, guint index)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
GstChildProxyInterface *iface;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), NULL);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
iface = GST_CHILD_PROXY_GET_INTERFACE (parent);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (iface->get_child_by_index != NULL)
|
|
Packit Service |
963350 |
return iface->get_child_by_index (parent, index);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
return NULL;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_get_children_count:
|
|
Packit Service |
963350 |
* @parent: the parent object
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Gets the number of child objects this parent contains.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Returns: the number of child objects
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* MT safe.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
guint
|
|
Packit Service |
963350 |
gst_child_proxy_get_children_count (GstChildProxy * parent)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
GstChildProxyInterface *iface;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), 0);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
iface = GST_CHILD_PROXY_GET_INTERFACE (parent);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (iface->get_children_count != NULL)
|
|
Packit Service |
963350 |
return iface->get_children_count (parent);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
return 0;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_lookup:
|
|
Packit Service |
963350 |
* @object: child proxy object to lookup the property in
|
|
Packit Service |
963350 |
* @name: name of the property to look up
|
|
Packit Service |
963350 |
* @target: (out) (allow-none) (transfer full): pointer to a #GObject that
|
|
Packit Service |
963350 |
* takes the real object to set property on
|
|
Packit Service |
963350 |
* @pspec: (out) (allow-none) (transfer none): pointer to take the #GParamSpec
|
|
Packit Service |
963350 |
* describing the property
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Looks up which object and #GParamSpec would be effected by the given @name.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* MT safe.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Returns: %TRUE if @target and @pspec could be found. %FALSE otherwise. In that
|
|
Packit Service |
963350 |
* case the values for @pspec and @target are not modified. Unref @target after
|
|
Packit Service |
963350 |
* usage. For plain GObjects @target is the same as @object.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
gboolean
|
|
Packit Service |
963350 |
gst_child_proxy_lookup (GstChildProxy * object, const gchar * name,
|
|
Packit Service |
963350 |
GObject ** target, GParamSpec ** pspec)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
GObject *obj;
|
|
Packit Service |
963350 |
gboolean res = FALSE;
|
|
Packit Service |
963350 |
gchar **names, **current;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_return_val_if_fail (GST_IS_CHILD_PROXY (object), FALSE);
|
|
Packit Service |
963350 |
g_return_val_if_fail (name != NULL, FALSE);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
obj = G_OBJECT (g_object_ref (object));
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
current = names = g_strsplit (name, "::", -1);
|
|
Packit Service |
963350 |
/* find the owner of the property */
|
|
Packit Service |
963350 |
while (current[1]) {
|
|
Packit Service |
963350 |
GObject *next;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (!GST_IS_CHILD_PROXY (obj)) {
|
|
Packit Service |
963350 |
GST_INFO
|
|
Packit Service |
963350 |
("object %s is not a parent, so you cannot request a child by name %s",
|
|
Packit Service |
963350 |
(GST_IS_OBJECT (obj) ? GST_OBJECT_NAME (obj) : ""), current[0]);
|
|
Packit Service |
963350 |
break;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
next = gst_child_proxy_get_child_by_name (GST_CHILD_PROXY (obj),
|
|
Packit Service |
963350 |
current[0]);
|
|
Packit Service |
963350 |
if (!next) {
|
|
Packit Service |
963350 |
GST_INFO ("no such object %s", current[0]);
|
|
Packit Service |
963350 |
break;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
g_object_unref (obj);
|
|
Packit Service |
963350 |
obj = next;
|
|
Packit Service |
963350 |
current++;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/* look for psec */
|
|
Packit Service |
963350 |
if (current[1] == NULL) {
|
|
Packit Service |
963350 |
GParamSpec *spec =
|
|
Packit Service |
963350 |
g_object_class_find_property (G_OBJECT_GET_CLASS (obj), current[0]);
|
|
Packit Service |
963350 |
if (spec == NULL) {
|
|
Packit Service |
963350 |
GST_INFO ("no param spec named %s", current[0]);
|
|
Packit Service |
963350 |
} else {
|
|
Packit Service |
963350 |
if (pspec)
|
|
Packit Service |
963350 |
*pspec = spec;
|
|
Packit Service |
963350 |
if (target) {
|
|
Packit Service |
963350 |
g_object_ref (obj);
|
|
Packit Service |
963350 |
*target = obj;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
res = TRUE;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
g_object_unref (obj);
|
|
Packit Service |
963350 |
g_strfreev (names);
|
|
Packit Service |
963350 |
return res;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_get_property:
|
|
Packit Service |
963350 |
* @object: object to query
|
|
Packit Service |
963350 |
* @name: name of the property
|
|
Packit Service |
963350 |
* @value: (out caller-allocates): a #GValue that should take the result.
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Gets a single property using the GstChildProxy mechanism.
|
|
Packit Service |
963350 |
* You are responsible for freeing it by calling g_value_unset()
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
void
|
|
Packit Service |
963350 |
gst_child_proxy_get_property (GstChildProxy * object, const gchar * name,
|
|
Packit Service |
963350 |
GValue * value)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
GParamSpec *pspec;
|
|
Packit Service |
963350 |
GObject *target;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
|
Packit Service |
963350 |
g_return_if_fail (name != NULL);
|
|
Packit Service |
963350 |
g_return_if_fail (G_IS_VALUE (value));
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (!gst_child_proxy_lookup (object, name, &target, &pspec))
|
|
Packit Service |
963350 |
goto not_found;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_object_get_property (target, pspec->name, value);
|
|
Packit Service |
963350 |
g_object_unref (target);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
return;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
not_found:
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
g_warning ("no property %s in object %s", name,
|
|
Packit Service |
963350 |
(GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""));
|
|
Packit Service |
963350 |
return;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_get_valist:
|
|
Packit Service |
963350 |
* @object: the object to query
|
|
Packit Service |
963350 |
* @first_property_name: name of the first property to get
|
|
Packit Service |
963350 |
* @var_args: return location for the first property, followed optionally by more name/return location pairs, followed by %NULL
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Gets properties of the parent object and its children.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
void
|
|
Packit Service |
963350 |
gst_child_proxy_get_valist (GstChildProxy * object,
|
|
Packit Service |
963350 |
const gchar * first_property_name, va_list var_args)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
const gchar *name;
|
|
Packit Service |
963350 |
gchar *error = NULL;
|
|
Packit Service |
963350 |
GValue value = { 0, };
|
|
Packit Service |
963350 |
GParamSpec *pspec;
|
|
Packit Service |
963350 |
GObject *target;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
name = first_property_name;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/* iterate over pairs */
|
|
Packit Service |
963350 |
while (name) {
|
|
Packit Service |
963350 |
if (!gst_child_proxy_lookup (object, name, &target, &pspec))
|
|
Packit Service |
963350 |
goto not_found;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_value_init (&value, pspec->value_type);
|
|
Packit Service |
963350 |
g_object_get_property (target, pspec->name, &value);
|
|
Packit Service |
963350 |
g_object_unref (target);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
G_VALUE_LCOPY (&value, var_args, 0, &error);
|
|
Packit Service |
963350 |
if (error)
|
|
Packit Service |
963350 |
goto cant_copy;
|
|
Packit Service |
963350 |
g_value_unset (&value);
|
|
Packit Service |
963350 |
name = va_arg (var_args, gchar *);
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
return;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
not_found:
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
g_warning ("no property %s in object %s", name,
|
|
Packit Service |
963350 |
(GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""));
|
|
Packit Service |
963350 |
return;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
cant_copy:
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
g_warning ("error copying value %s in object %s: %s", pspec->name,
|
|
Packit Service |
963350 |
(GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""), error);
|
|
Packit Service |
963350 |
g_value_unset (&value);
|
|
Packit Service |
963350 |
return;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_get:
|
|
Packit Service |
963350 |
* @object: the parent object
|
|
Packit Service |
963350 |
* @first_property_name: name of the first property to get
|
|
Packit Service |
963350 |
* @...: return location for the first property, followed optionally by more name/return location pairs, followed by %NULL
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Gets properties of the parent object and its children.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
void
|
|
Packit Service |
963350 |
gst_child_proxy_get (GstChildProxy * object, const gchar * first_property_name,
|
|
Packit Service |
963350 |
...)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
va_list var_args;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
va_start (var_args, first_property_name);
|
|
Packit Service |
963350 |
gst_child_proxy_get_valist (object, first_property_name, var_args);
|
|
Packit Service |
963350 |
va_end (var_args);
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_set_property:
|
|
Packit Service |
963350 |
* @object: the parent object
|
|
Packit Service |
963350 |
* @name: name of the property to set
|
|
Packit Service |
963350 |
* @value: new #GValue for the property
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Sets a single property using the GstChildProxy mechanism.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
void
|
|
Packit Service |
963350 |
gst_child_proxy_set_property (GstChildProxy * object, const gchar * name,
|
|
Packit Service |
963350 |
const GValue * value)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
GParamSpec *pspec;
|
|
Packit Service |
963350 |
GObject *target;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
|
Packit Service |
963350 |
g_return_if_fail (name != NULL);
|
|
Packit Service |
963350 |
g_return_if_fail (G_IS_VALUE (value));
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (!gst_child_proxy_lookup (object, name, &target, &pspec))
|
|
Packit Service |
963350 |
goto not_found;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_object_set_property (target, pspec->name, value);
|
|
Packit Service |
963350 |
g_object_unref (target);
|
|
Packit Service |
963350 |
return;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
not_found:
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
g_warning ("cannot set property %s on object %s", name,
|
|
Packit Service |
963350 |
(GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""));
|
|
Packit Service |
963350 |
return;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_set_valist:
|
|
Packit Service |
963350 |
* @object: the parent object
|
|
Packit Service |
963350 |
* @first_property_name: name of the first property to set
|
|
Packit Service |
963350 |
* @var_args: value for the first property, followed optionally by more name/value pairs, followed by %NULL
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Sets properties of the parent object and its children.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
void
|
|
Packit Service |
963350 |
gst_child_proxy_set_valist (GstChildProxy * object,
|
|
Packit Service |
963350 |
const gchar * first_property_name, va_list var_args)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
const gchar *name;
|
|
Packit Service |
963350 |
gchar *error = NULL;
|
|
Packit Service |
963350 |
GValue value = { 0, };
|
|
Packit Service |
963350 |
GParamSpec *pspec;
|
|
Packit Service |
963350 |
GObject *target;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
name = first_property_name;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/* iterate over pairs */
|
|
Packit Service |
963350 |
while (name) {
|
|
Packit Service |
963350 |
if (!gst_child_proxy_lookup (object, name, &target, &pspec))
|
|
Packit Service |
963350 |
goto not_found;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
G_VALUE_COLLECT_INIT (&value, pspec->value_type, var_args,
|
|
Packit Service |
963350 |
G_VALUE_NOCOPY_CONTENTS, &error);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (error)
|
|
Packit Service |
963350 |
goto cant_copy;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_object_set_property (target, pspec->name, &value);
|
|
Packit Service |
963350 |
g_object_unref (target);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_value_unset (&value);
|
|
Packit Service |
963350 |
name = va_arg (var_args, gchar *);
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
return;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
not_found:
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
g_warning ("no property %s in object %s", name,
|
|
Packit Service |
963350 |
(GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""));
|
|
Packit Service |
963350 |
return;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
cant_copy:
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
g_warning ("error copying value %s in object %s: %s", pspec->name,
|
|
Packit Service |
963350 |
(GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""), error);
|
|
Packit Service |
963350 |
g_value_unset (&value);
|
|
Packit Service |
963350 |
g_object_unref (target);
|
|
Packit Service |
963350 |
return;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_set:
|
|
Packit Service |
963350 |
* @object: the parent object
|
|
Packit Service |
963350 |
* @first_property_name: name of the first property to set
|
|
Packit Service |
963350 |
* @...: value for the first property, followed optionally by more name/value pairs, followed by %NULL
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Sets properties of the parent object and its children.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
void
|
|
Packit Service |
963350 |
gst_child_proxy_set (GstChildProxy * object, const gchar * first_property_name,
|
|
Packit Service |
963350 |
...)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
va_list var_args;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_return_if_fail (GST_IS_CHILD_PROXY (object));
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
va_start (var_args, first_property_name);
|
|
Packit Service |
963350 |
gst_child_proxy_set_valist (object, first_property_name, var_args);
|
|
Packit Service |
963350 |
va_end (var_args);
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_child_added:
|
|
Packit Service |
963350 |
* @parent: the parent object
|
|
Packit Service |
963350 |
* @child: the newly added child
|
|
Packit Service |
963350 |
* @name: the name of the new child
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Emits the "child-added" signal.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
void
|
|
Packit Service |
963350 |
gst_child_proxy_child_added (GstChildProxy * parent, GObject * child,
|
|
Packit Service |
963350 |
const gchar * name)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
g_signal_emit (parent, signals[CHILD_ADDED], 0, child, name);
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* gst_child_proxy_child_removed:
|
|
Packit Service |
963350 |
* @parent: the parent object
|
|
Packit Service |
963350 |
* @child: the removed child
|
|
Packit Service |
963350 |
* @name: the name of the old child
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Emits the "child-removed" signal.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
void
|
|
Packit Service |
963350 |
gst_child_proxy_child_removed (GstChildProxy * parent, GObject * child,
|
|
Packit Service |
963350 |
const gchar * name)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
g_signal_emit (parent, signals[CHILD_REMOVED], 0, child, name);
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/* gobject methods */
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
static void
|
|
Packit Service |
963350 |
gst_child_proxy_class_init (gpointer g_class, gpointer class_data)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
GstChildProxyInterface *iface = (GstChildProxyInterface *) g_class;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
iface->get_child_by_name = gst_child_proxy_default_get_child_by_name;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
static void
|
|
Packit Service |
963350 |
gst_child_proxy_base_init (gpointer g_class)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
static gboolean initialized = FALSE;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (!initialized) {
|
|
Packit Service |
963350 |
/* create interface signals and properties here. */
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* GstChildProxy::child-added:
|
|
Packit Service |
963350 |
* @child_proxy: the #GstChildProxy
|
|
Packit Service |
963350 |
* @object: the #GObject that was added
|
|
Packit Service |
963350 |
* @name: the name of the new child
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Will be emitted after the @object was added to the @child_proxy.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
signals[CHILD_ADDED] =
|
|
Packit Service |
963350 |
g_signal_new ("child-added", G_TYPE_FROM_CLASS (g_class),
|
|
Packit Service |
963350 |
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GstChildProxyInterface,
|
|
Packit Service |
963350 |
child_added), NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE,
|
|
Packit Service |
963350 |
2, G_TYPE_OBJECT, G_TYPE_STRING);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
/**
|
|
Packit Service |
963350 |
* GstChildProxy::child-removed:
|
|
Packit Service |
963350 |
* @child_proxy: the #GstChildProxy
|
|
Packit Service |
963350 |
* @object: the #GObject that was removed
|
|
Packit Service |
963350 |
* @name: the name of the old child
|
|
Packit Service |
963350 |
*
|
|
Packit Service |
963350 |
* Will be emitted after the @object was removed from the @child_proxy.
|
|
Packit Service |
963350 |
*/
|
|
Packit Service |
963350 |
signals[CHILD_REMOVED] =
|
|
Packit Service |
963350 |
g_signal_new ("child-removed", G_TYPE_FROM_CLASS (g_class),
|
|
Packit Service |
963350 |
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GstChildProxyInterface,
|
|
Packit Service |
963350 |
child_removed), NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE,
|
|
Packit Service |
963350 |
2, G_TYPE_OBJECT, G_TYPE_STRING);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
initialized = TRUE;
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
GType
|
|
Packit Service |
963350 |
gst_child_proxy_get_type (void)
|
|
Packit Service |
963350 |
{
|
|
Packit Service |
963350 |
static volatile gsize type = 0;
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
if (g_once_init_enter (&type)) {
|
|
Packit Service |
963350 |
GType _type;
|
|
Packit Service |
963350 |
static const GTypeInfo info = {
|
|
Packit Service |
963350 |
sizeof (GstChildProxyInterface),
|
|
Packit Service |
963350 |
gst_child_proxy_base_init, /* base_init */
|
|
Packit Service |
963350 |
NULL, /* base_finalize */
|
|
Packit Service |
963350 |
gst_child_proxy_class_init, /* class_init */
|
|
Packit Service |
963350 |
NULL, /* class_finalize */
|
|
Packit Service |
963350 |
NULL, /* class_data */
|
|
Packit Service |
963350 |
0,
|
|
Packit Service |
963350 |
0, /* n_preallocs */
|
|
Packit Service |
963350 |
NULL /* instance_init */
|
|
Packit Service |
963350 |
};
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
_type =
|
|
Packit Service |
963350 |
g_type_register_static (G_TYPE_INTERFACE, "GstChildProxy", &info, 0);
|
|
Packit Service |
963350 |
|
|
Packit Service |
963350 |
g_type_interface_add_prerequisite (_type, G_TYPE_OBJECT);
|
|
Packit Service |
963350 |
g_once_init_leave (&type, (gsize) _type);
|
|
Packit Service |
963350 |
}
|
|
Packit Service |
963350 |
return type;
|
|
Packit Service |
963350 |
}
|