+gst_parse_free_delayed_set (DelayedSet *set)
+{
+ g_free(set->name);
+ g_free(set->value_str);
+ g_slice_free(DelayedSet, set);
+}
+
+static void gst_parse_new_child(GstChildProxy *child_proxy, GObject *object,
+ gpointer data);
+
+static void
+gst_parse_add_delayed_set (GstElement *element, gchar *name, gchar *value_str)
+{
+ DelayedSet *data = g_slice_new0 (DelayedSet);
+
+ GST_CAT_LOG_OBJECT (GST_CAT_PIPELINE, element, "delaying property set %s to %s",
+ name, value_str);
+
+ data->name = g_strdup(name);
+ data->value_str = g_strdup(value_str);
+ data->signal_id = g_signal_connect_data(element, "child-added",
+ G_CALLBACK (gst_parse_new_child), data, (GClosureNotify)
+ gst_parse_free_delayed_set, (GConnectFlags) 0);
+
+ /* FIXME: we would need to listen on all intermediate bins too */
+ if (GST_IS_BIN (element)) {
+ gchar **names, **current;
+ GstElement *parent, *child;
+
+ current = names = g_strsplit (name, "::", -1);
+ parent = gst_bin_get_by_name (GST_BIN_CAST (element), current[0]);
+ current++;
+ while (parent && current[0]) {
+ child = gst_bin_get_by_name (GST_BIN (parent), current[0]);
+ if (!child && current[1]) {
+ char *sub_name = g_strjoinv ("::", ¤t[0]);
+
+ gst_parse_add_delayed_set(parent, sub_name, value_str);
+ g_free (sub_name);
+ }
+ parent = child;
+ current++;
+ }
+ g_strfreev (names);
+ }
+}
+
+static void gst_parse_new_child(GstChildProxy *child_proxy, GObject *object,
+ gpointer data)
+{
+ DelayedSet *set = (DelayedSet *) data;
+ GParamSpec *pspec;
+ GValue v = { 0, };
+ GstObject *target = NULL;
+ GType value_type;
+
+ GST_CAT_LOG_OBJECT (GST_CAT_PIPELINE, child_proxy, "new child %s, checking property %s",
+ GST_OBJECT_NAME(object), set->name);
+
+ if (gst_child_proxy_lookup (G_OBJECT (child_proxy), set->name, &target, &pspec)) {
+ gboolean got_value = FALSE;
+
+ value_type = pspec->value_type;
+
+ GST_CAT_LOG_OBJECT (GST_CAT_PIPELINE, child_proxy, "parsing delayed property %s as a %s from %s",
+ pspec->name, g_type_name (value_type), set->value_str);
+ g_value_init (&v, value_type);
+ if (gst_value_deserialize (&v, set->value_str))
+ got_value = TRUE;
+ else if (g_type_is_a (value_type, GST_TYPE_ELEMENT)) {
+ GstElement *bin;
+
+ bin = gst_parse_bin_from_description (set->value_str, TRUE, NULL);
+ if (bin) {
+ g_value_set_object (&v, bin);
+ got_value = TRUE;
+ }
+ }
+ g_signal_handler_disconnect (child_proxy, set->signal_id);
+ if (!got_value)
+ goto error;
+ g_object_set_property (G_OBJECT (target), pspec->name, &v);
+ } else {
+ const gchar *obj_name = GST_OBJECT_NAME(object);
+ gint len = strlen (obj_name);
+
+ /* do a delayed set */
+ if ((strlen (set->name) > (len + 2)) && !strncmp (set->name, obj_name, len) && !strncmp (&set->name[len], "::", 2)) {
+ gst_parse_add_delayed_set (GST_ELEMENT(child_proxy), set->name, set->value_str);
+ }
+ }
+
+out:
+ if (G_IS_VALUE (&v))
+ g_value_unset (&v);
+ if (target)
+ gst_object_unref (target);
+ return;
+
+error:
+ GST_CAT_ERROR (GST_CAT_PIPELINE, "could not set property \"%s\" in element \"%s\"",
+ pspec->name, GST_ELEMENT_NAME (target));
+ goto out;
+}
+
+static void