gstreamer: parse: Use child proxy for deferred property setting

We use that mechanism for the non-deferred path, and this makes sure we are
consistent for deferred set too.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7519>
This commit is contained in:
Arun Raghavan 2024-09-16 08:48:47 -04:00 committed by GStreamer Marge Bot
parent 92d8da92dc
commit 90e58aec3c

View file

@ -348,48 +348,47 @@ static void gst_parse_free_delayed_set (DelayedSet *set)
static void gst_parse_new_child (GstChildProxy *child_proxy, GObject *object, static void gst_parse_new_child (GstChildProxy *child_proxy, GObject *object,
const gchar * name, gpointer data); const gchar * name, gpointer data);
static void gst_parse_add_delayed_set (GstElement *element, gchar *name, gchar *value_str) static void gst_parse_add_delayed_set (GstChildProxy *proxy, gchar *name, gchar *value_str)
{ {
DelayedSet *data = g_new0 (DelayedSet, 1); DelayedSet *data = g_new0 (DelayedSet, 1);
gchar **names, **current;
GObject *parent, *child;
GST_CAT_LOG_OBJECT (GST_CAT_PIPELINE, element, "delaying property set %s to %s", GST_CAT_LOG_OBJECT (GST_CAT_PIPELINE, proxy, "delaying property set %s to %s",
name, value_str); name, value_str);
data->name = g_strdup(name); data->name = g_strdup (name);
data->value_str = g_strdup(value_str); data->value_str = g_strdup (value_str);
data->signal_id = g_signal_connect_data(element, "child-added", data->signal_id = g_signal_connect_data (proxy, "child-added",
G_CALLBACK (gst_parse_new_child), data, (GClosureNotify) G_CALLBACK (gst_parse_new_child), data, (GClosureNotify)
gst_parse_free_delayed_set, (GConnectFlags) 0); gst_parse_free_delayed_set, (GConnectFlags) 0);
/* FIXME: we would need to listen on all intermediate bins too */ current = names = g_strsplit (name, "::", -1);
if (GST_IS_BIN (element)) { parent = gst_child_proxy_get_child_by_name (GST_CHILD_PROXY (proxy), current[0]);
gchar **names, **current; current++;
GstElement *parent, *child;
current = names = g_strsplit (name, "::", -1); while (parent && current[0]) {
parent = gst_bin_get_by_name (GST_BIN_CAST (element), current[0]); if (!GST_IS_CHILD_PROXY (parent)) {
current++; GST_INFO ("Not recursing into non-proxy child %p", parent);
while (parent && current[0]) { break;
if (!GST_IS_BIN (parent)) {
GST_INFO ("Not recursing into non-bin child %s",
gst_object_get_name (GST_OBJECT (parent)));
break;
}
child = gst_bin_get_by_name (GST_BIN (parent), current[0]);
if (!child && current[1]) {
char *sub_name = g_strjoinv ("::", &current[0]);
gst_parse_add_delayed_set(parent, sub_name, value_str);
g_free (sub_name);
}
gst_object_unref (parent);
parent = child;
current++;
} }
if (parent)
gst_object_unref (parent); child = gst_child_proxy_get_child_by_name (GST_CHILD_PROXY (parent), current[0]);
g_strfreev (names); if (!child && current[1]) {
char *sub_name = g_strjoinv ("::", &current[0]);
gst_parse_add_delayed_set (GST_CHILD_PROXY (parent), sub_name, value_str);
g_free (sub_name);
}
gst_object_unref (parent);
parent = child;
current++;
} }
if (parent)
gst_object_unref (parent);
g_strfreev (names);
} }
static gboolean static gboolean
@ -493,7 +492,7 @@ static void gst_parse_new_child(GstChildProxy *child_proxy, GObject *object,
/* Case 1: A child in the hierarchy does not exist yet, add a new delayed set */ /* Case 1: A child in the hierarchy does not exist yet, add a new delayed set */
if (NULL == child) { if (NULL == child) {
gst_parse_add_delayed_set (GST_ELEMENT (child_proxy), set->name, set->value_str); gst_parse_add_delayed_set (child_proxy, set->name, set->value_str);
} }
/* Case 2: The target child exists already but there's no such property */ /* Case 2: The target child exists already but there's no such property */
else { else {
@ -715,7 +714,7 @@ static GstElement * gst_parse_element_make (graph_t *graph, element_t *data) {
g_free (property); g_free (property);
if (target == NULL) { if (target == NULL) {
gst_parse_add_delayed_set (ret, pp->name, pp->value); gst_parse_add_delayed_set (GST_CHILD_PROXY (ret), pp->name, pp->value);
} else { } else {
gst_object_unref (target); gst_object_unref (target);
SET_ERROR (graph->error, GST_PARSE_ERROR_NO_SUCH_PROPERTY, \ SET_ERROR (graph->error, GST_PARSE_ERROR_NO_SUCH_PROPERTY, \
@ -821,7 +820,7 @@ static void gst_parse_element_set (gchar *value, GstElement *element, graph_t *g
the child was found, we fail since the property doesn't exist. the child was found, we fail since the property doesn't exist.
*/ */
if (!gst_parse_child_proxy_find_child (GST_CHILD_PROXY (element), value)) { if (!gst_parse_child_proxy_find_child (GST_CHILD_PROXY (element), value)) {
gst_parse_add_delayed_set (element, value, pos); gst_parse_add_delayed_set (GST_CHILD_PROXY (element), value, pos);
} else { } else {
goto error; goto error;
} }