#define gst_bin_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstBin, gst_bin, GST_TYPE_ELEMENT, _do_init);
-static GstObject *
+static GObject *
gst_bin_child_proxy_get_child_by_index (GstChildProxy * child_proxy,
guint index)
{
gst_object_ref (res);
GST_OBJECT_UNLOCK (bin);
- return res;
+ return (GObject *) res;
}
static guint
g_free (elem_name);
g_signal_emit (bin, gst_bin_signals[ELEMENT_ADDED], 0, element);
- gst_child_proxy_child_added ((GstObject *) bin, (GstObject *) element);
+ gst_child_proxy_child_added ((GObject *) bin, (GObject *) element);
return TRUE;
GST_OBJECT_UNLOCK (element);
g_signal_emit (bin, gst_bin_signals[ELEMENT_REMOVED], 0, element);
- gst_child_proxy_child_removed ((GstObject *) bin, (GstObject *) element);
+ gst_child_proxy_child_removed ((GObject *) bin, (GObject *) element);
/* element is really out of our control now */
gst_object_unref (element);
* scheme is recursive. Thus "child1::child2::property" is valid too, if
* "child1" and "child2" implement the #GstChildProxy interface.
*/
-/* FIXME-0.11:
- * it would be nice to use GObject instead of GstObject.
- * This change would allow to propose the interface for inclusion with
- * glib/gobject. IMHO this is useful for GtkContainer and compound widgets too.
- */
#include "gst_private.h"
static guint signals[LAST_SIGNAL] = { 0 };
-static GstObject *
+static GObject *
gst_child_proxy_default_get_child_by_name (GstChildProxy * parent,
const gchar * name)
{
guint count, i;
- GstObject *object, *result;
+ GObject *object, *result;
gchar *object_name;
g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), NULL);
if (!(object = gst_child_proxy_get_child_by_index (parent, i)))
continue;
- object_name = gst_object_get_name (object);
+ if (!GST_IS_OBJECT (object)) {
+ goto next;
+ }
+ object_name = gst_object_get_name (GST_OBJECT_CAST (object));
if (object_name == NULL) {
g_warning ("child %u of parent %s has no name", i,
GST_OBJECT_NAME (parent));
break;
}
next:
- gst_object_unref (object);
+ g_object_unref (object);
}
return result;
}
*
* Looks up a child element by the given name.
*
- * Implementors can use #GstObject together with gst_object_get_name()
+ * This virtual method has a default implementation that uses #GstObject
+ * together with gst_object_get_name(). If the interface is to be used with
+ * #GObjects, this methods needs to be overridden.
*
* Returns: (transfer full): the child object or %NULL if not found. Unref
* after usage.
*
* MT safe.
*/
-GstObject *
+GObject *
gst_child_proxy_get_child_by_name (GstChildProxy * parent, const gchar * name)
{
g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), 0);
*
* MT safe.
*/
-GstObject *
+GObject *
gst_child_proxy_get_child_by_index (GstChildProxy * parent, guint index)
{
g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), NULL);
* gst_child_proxy_lookup:
* @object: object to lookup the property in
* @name: name of the property to look up
- * @target: (out) (allow-none) (transfer full): pointer to a #GstObject that
+ * @target: (out) (allow-none) (transfer full): pointer to a #GObject that
* takes the real object to set property on
* @pspec: (out) (allow-none) (transfer full): pointer to take the #GParamSpec
* describing the property
* MT safe.
*/
gboolean
-gst_child_proxy_lookup (GstObject * object, const gchar * name,
- GstObject ** target, GParamSpec ** pspec)
+gst_child_proxy_lookup (GObject * object, const gchar * name,
+ GObject ** target, GParamSpec ** pspec)
{
gboolean res = FALSE;
gchar **names, **current;
current = names = g_strsplit (name, "::", -1);
while (current[1]) {
- GstObject *next;
+ GObject *next;
if (!GST_IS_CHILD_PROXY (object)) {
GST_INFO
* You are responsible for freeing it by calling g_value_unset()
*/
void
-gst_child_proxy_get_property (GstObject * object, const gchar * name,
+gst_child_proxy_get_property (GObject * object, const gchar * name,
GValue * value)
{
GParamSpec *pspec;
- GstObject *target;
+ GObject *target;
g_return_if_fail (GST_IS_OBJECT (object));
g_return_if_fail (name != NULL);
* Gets properties of the parent object and its children.
*/
void
-gst_child_proxy_get_valist (GstObject * object,
+gst_child_proxy_get_valist (GObject * object,
const gchar * first_property_name, va_list var_args)
{
const gchar *name;
gchar *error = NULL;
GValue value = { 0, };
GParamSpec *pspec;
- GstObject *target;
+ GObject *target;
g_return_if_fail (G_IS_OBJECT (object));
* Gets properties of the parent object and its children.
*/
void
-gst_child_proxy_get (GstObject * object, const gchar * first_property_name, ...)
+gst_child_proxy_get (GObject * object, const gchar * first_property_name, ...)
{
va_list var_args;
* Sets a single property using the GstChildProxy mechanism.
*/
void
-gst_child_proxy_set_property (GstObject * object, const gchar * name,
+gst_child_proxy_set_property (GObject * object, const gchar * name,
const GValue * value)
{
GParamSpec *pspec;
- GstObject *target;
+ GObject *target;
g_return_if_fail (GST_IS_OBJECT (object));
g_return_if_fail (name != NULL);
* Sets properties of the parent object and its children.
*/
void
-gst_child_proxy_set_valist (GstObject * object,
+gst_child_proxy_set_valist (GObject * object,
const gchar * first_property_name, va_list var_args)
{
const gchar *name;
gchar *error = NULL;
GValue value = { 0, };
GParamSpec *pspec;
- GstObject *target;
+ GObject *target;
g_return_if_fail (G_IS_OBJECT (object));
* Sets properties of the parent object and its children.
*/
void
-gst_child_proxy_set (GstObject * object, const gchar * first_property_name, ...)
+gst_child_proxy_set (GObject * object, const gchar * first_property_name, ...)
{
va_list var_args;
* Emits the "child-added" signal.
*/
void
-gst_child_proxy_child_added (GstObject * object, GstObject * child)
+gst_child_proxy_child_added (GObject * object, GObject * child)
{
g_signal_emit (G_OBJECT (object), signals[CHILD_ADDED], 0, child);
}
* Emits the "child-removed" signal.
*/
void
-gst_child_proxy_child_removed (GstObject * object, GstObject * child)
+gst_child_proxy_child_removed (GObject * object, GObject * child)
{
g_signal_emit (G_OBJECT (object), signals[CHILD_REMOVED], 0, child);
}
GTypeInterface parent;
/* methods */
- GstObject * (*get_child_by_name) (GstChildProxy * parent, const gchar * name);
- GstObject * (*get_child_by_index) (GstChildProxy * parent, guint index);
- guint (*get_children_count) (GstChildProxy * parent);
+ GObject * (*get_child_by_name) (GstChildProxy * parent, const gchar * name);
+ GObject * (*get_child_by_index) (GstChildProxy * parent, guint index);
+ guint (*get_children_count) (GstChildProxy * parent);
/*< private >*/
/* signals */
- void (*child_added) (GstChildProxy * parent, GstObject * child);
- void (*child_removed) (GstChildProxy * parent, GstObject * child);
+ void (*child_added) (GstChildProxy * parent, GObject * child);
+ void (*child_removed) (GstChildProxy * parent, GObject * child);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_child_proxy_get_type (void);
+GType gst_child_proxy_get_type (void);
-GstObject * gst_child_proxy_get_child_by_name (GstChildProxy * parent, const gchar * name);
+GObject * gst_child_proxy_get_child_by_name (GstChildProxy * parent, const gchar * name);
-guint gst_child_proxy_get_children_count (GstChildProxy * parent);
-GstObject * gst_child_proxy_get_child_by_index (GstChildProxy * parent, guint index);
+guint gst_child_proxy_get_children_count (GstChildProxy * parent);
+GObject * gst_child_proxy_get_child_by_index (GstChildProxy * parent, guint index);
-gboolean gst_child_proxy_lookup (GstObject *object, const gchar *name,
- GstObject **target, GParamSpec **pspec);
+gboolean gst_child_proxy_lookup (GObject *object, const gchar *name,
+ GObject **target, GParamSpec **pspec);
-void gst_child_proxy_get_property (GstObject * object, const gchar *name,
- GValue *value);
-void gst_child_proxy_get_valist (GstObject * object,
- const gchar * first_property_name,
- va_list var_args);
-void gst_child_proxy_get (GstObject * object,
- const gchar * first_property_name,
- ...) G_GNUC_NULL_TERMINATED;
+void gst_child_proxy_get_property (GObject * object, const gchar *name,
+ GValue *value);
+void gst_child_proxy_get_valist (GObject * object,
+ const gchar * first_property_name,
+ va_list var_args);
+void gst_child_proxy_get (GObject * object,
+ const gchar * first_property_name,
+ ...) G_GNUC_NULL_TERMINATED;
-void gst_child_proxy_set_property (GstObject * object, const gchar *name,
- const GValue *value);
-void gst_child_proxy_set_valist (GstObject* object,
- const gchar * first_property_name,
- va_list var_args);
-void gst_child_proxy_set (GstObject * object,
- const gchar * first_property_name,
- ...) G_GNUC_NULL_TERMINATED;
+void gst_child_proxy_set_property (GObject * object, const gchar *name,
+ const GValue *value);
+void gst_child_proxy_set_valist (GObject* object,
+ const gchar * first_property_name,
+ va_list var_args);
+void gst_child_proxy_set (GObject * object,
+ const gchar * first_property_name,
+ ...) G_GNUC_NULL_TERMINATED;
-void gst_child_proxy_child_added (GstObject * object, GstObject * child);
-void gst_child_proxy_child_removed (GstObject * object, GstObject * child);
+void gst_child_proxy_child_added (GObject * object, GObject * child);
+void gst_child_proxy_child_removed (GObject * object, GObject * child);
G_END_DECLS
pipeline = gst_pipeline_new ("foo");
fail_unless (pipeline != NULL, "Could not create pipeline");
- gst_child_proxy_get (GST_OBJECT (pipeline), "name", &name, NULL);
+ gst_child_proxy_get (G_OBJECT (pipeline), "name", &name, NULL);
fail_if (g_strcmp0 ("foo", name));
g_free (name);
gst_bin_add (GST_BIN (pipeline), elem);
- gst_child_proxy_get (GST_OBJECT (pipeline), "src::name", &name, NULL);
+ gst_child_proxy_get (G_OBJECT (pipeline), "src::name", &name, NULL);
fail_if (g_strcmp0 ("src", name));
g_free (name);