ghostpad: Don't change the ghostpad caps immediately when the peer caps change

This should only happen during data-flow.
This commit is contained in:
Sebastian Dröge 2012-06-08 10:26:02 +02:00
parent 6cdc416273
commit d563379085
2 changed files with 0 additions and 177 deletions

View file

@ -74,9 +74,6 @@ static xmlNodePtr gst_proxy_pad_save_thyself (GstObject * object,
xmlNodePtr parent);
#endif
static void on_src_target_notify (GstPad * target,
GParamSpec * unused, gpointer user_data);
static GParamSpec *pspec_caps = NULL;
/**
@ -678,8 +675,6 @@ struct _GstGhostPadPrivate
{
/* with PROXY_LOCK */
gulong notify_id;
gulong target_caps_notify_id;
gulong target_unlinked_id;
gboolean constructed;
};
@ -903,65 +898,6 @@ on_int_notify (GstPad * internal, GParamSpec * unused, GstGhostPad * pad)
gst_caps_unref (caps);
}
static void
on_src_target_notify (GstPad * target, GParamSpec * unused, gpointer user_data)
{
GstProxyPad *proxypad;
GstGhostPad *gpad;
GstCaps *caps;
g_object_get (target, "caps", &caps, NULL);
GST_OBJECT_LOCK (target);
/* First check if the peer is still available and our proxy pad */
if (!GST_PAD_PEER (target) || !GST_IS_PROXY_PAD (GST_PAD_PEER (target))) {
GST_OBJECT_UNLOCK (target);
goto done;
}
proxypad = GST_PROXY_PAD (GST_PAD_PEER (target));
GST_OBJECT_LOCK (proxypad);
/* Now check if the proxypad's internal pad is still there and
* a ghostpad */
if (!GST_PROXY_PAD_INTERNAL (proxypad) ||
!GST_IS_GHOST_PAD (GST_PROXY_PAD_INTERNAL (proxypad))) {
GST_OBJECT_UNLOCK (proxypad);
GST_OBJECT_UNLOCK (target);
goto done;
}
gpad = GST_GHOST_PAD (GST_PROXY_PAD_INTERNAL (proxypad));
g_object_ref (gpad);
GST_OBJECT_UNLOCK (proxypad);
GST_OBJECT_UNLOCK (target);
gst_pad_set_caps (GST_PAD_CAST (gpad), caps);
g_object_unref (gpad);
done:
if (caps)
gst_caps_unref (caps);
}
static void
on_src_target_unlinked (GstPad * pad, GstPad * peer, GstGhostPad * gpad)
{
GST_DEBUG_OBJECT (pad, "unlinked");
GST_DEBUG_OBJECT (gpad, "unlinked");
if (GST_GHOST_PAD_PRIVATE (gpad)->target_caps_notify_id) {
g_signal_handler_disconnect (pad,
GST_GHOST_PAD_PRIVATE (gpad)->target_caps_notify_id);
GST_GHOST_PAD_PRIVATE (gpad)->target_caps_notify_id = 0;
}
/* And remove our signal */
if (GST_GHOST_PAD_PRIVATE (gpad)->target_unlinked_id) {
g_signal_handler_disconnect (pad,
GST_GHOST_PAD_PRIVATE (gpad)->target_unlinked_id);
GST_GHOST_PAD_PRIVATE (gpad)->target_unlinked_id = 0;
}
}
/**
* gst_ghost_pad_setcaps_default:
* @pad: the #GstPad to link.
@ -1428,15 +1364,6 @@ gst_ghost_pad_set_target (GstGhostPad * gpad, GstPad * newtarget)
}
if (newtarget) {
if (GST_PAD_IS_SRC (newtarget)) {
GST_GHOST_PAD_PRIVATE (gpad)->target_caps_notify_id =
g_signal_connect (newtarget, "notify::caps",
G_CALLBACK (on_src_target_notify), NULL);
GST_GHOST_PAD_PRIVATE (gpad)->target_unlinked_id =
g_signal_connect (newtarget, "unlinked",
G_CALLBACK (on_src_target_unlinked), gpad);
}
/* and link to internal pad without any checks */
GST_DEBUG_OBJECT (gpad, "connecting internal pad to target");

View file

@ -670,109 +670,6 @@ GST_START_TEST (test_ghost_pads_new_no_target_from_template)
GST_END_TEST;
static void
ghost_notify_caps (GObject * object, GParamSpec * pspec, gpointer * user_data)
{
GST_DEBUG ("caps notify called");
(*(gint *) user_data)++;
}
GST_START_TEST (test_ghost_pads_forward_setcaps)
{
GstCaps *templ_caps, *caps1, *caps2;
GstPadTemplate *src_template, *sink_template;
GstPad *src, *ghost, *sink;
gint notify_counter = 0;
templ_caps = gst_caps_from_string ("meh; muh");
src_template = gst_pad_template_new ("src", GST_PAD_SRC,
GST_PAD_ALWAYS, templ_caps);
templ_caps = gst_caps_from_string ("muh; meh");
sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS, templ_caps);
src = gst_pad_new_from_template (src_template, "src");
sink = gst_pad_new_from_template (sink_template, "sink");
/* ghost source pad, setting caps on the source influences the caps of the
* ghostpad. */
ghost = gst_ghost_pad_new ("ghostsrc", src);
g_signal_connect (ghost, "notify::caps",
G_CALLBACK (ghost_notify_caps), &notify_counter);
fail_unless (gst_pad_link (ghost, sink) == GST_PAD_LINK_OK);
caps1 = gst_caps_from_string ("meh");
fail_unless (gst_pad_set_caps (src, caps1));
caps2 = GST_PAD_CAPS (ghost);
fail_unless (gst_caps_is_equal (caps1, caps2));
fail_unless_equals_int (notify_counter, 1);
gst_object_unref (ghost);
gst_caps_unref (caps1);
fail_unless (gst_pad_set_caps (src, NULL));
/* source 2, setting the caps on the ghostpad does not influence the caps of
* the target */
notify_counter = 0;
ghost = gst_ghost_pad_new ("ghostsrc", src);
g_signal_connect (ghost, "notify::caps",
G_CALLBACK (ghost_notify_caps), &notify_counter);
fail_unless (gst_pad_link (ghost, sink) == GST_PAD_LINK_OK);
caps1 = gst_caps_from_string ("meh");
fail_unless (gst_pad_set_caps (ghost, caps1));
caps2 = GST_PAD_CAPS (src);
fail_unless (caps2 == NULL);
fail_unless_equals_int (notify_counter, 1);
gst_object_unref (ghost);
gst_caps_unref (caps1);
/* ghost sink pad. Setting caps on the ghostpad will also set those caps on
* the target pad. */
notify_counter = 0;
ghost = gst_ghost_pad_new ("ghostsink", sink);
g_signal_connect (ghost, "notify::caps",
G_CALLBACK (ghost_notify_caps), &notify_counter);
fail_unless (gst_pad_link (src, ghost) == GST_PAD_LINK_OK);
caps1 = gst_caps_from_string ("muh");
fail_unless (gst_pad_set_caps (ghost, caps1));
caps2 = GST_PAD_CAPS (sink);
fail_unless (gst_caps_is_equal (caps1, caps2));
fail_unless_equals_int (notify_counter, 1);
gst_object_unref (ghost);
gst_caps_unref (caps1);
/* sink pad 2, setting caps just on the target pad should not influence the caps
* on the ghostpad. */
notify_counter = 0;
ghost = gst_ghost_pad_new ("ghostsink", sink);
g_signal_connect (ghost, "notify::caps",
G_CALLBACK (ghost_notify_caps), &notify_counter);
fail_unless (gst_pad_link (src, ghost) == GST_PAD_LINK_OK);
caps1 = gst_caps_from_string ("muh");
fail_unless (gst_pad_set_caps (sink, caps1));
caps2 = GST_PAD_CAPS (ghost);
fail_unless (caps2 == NULL);
fail_unless_equals_int (notify_counter, 0);
gst_object_unref (ghost);
gst_caps_unref (caps1);
gst_object_unref (src);
gst_object_unref (sink);
gst_object_unref (src_template);
gst_object_unref (sink_template);
}
GST_END_TEST;
static gint linked_count1;
static gint unlinked_count1;
static gint linked_count2;
@ -1099,7 +996,6 @@ gst_ghost_pad_suite (void)
tcase_add_test (tc_chain, test_ghost_pads_probes);
tcase_add_test (tc_chain, test_ghost_pads_new_from_template);
tcase_add_test (tc_chain, test_ghost_pads_new_no_target_from_template);
tcase_add_test (tc_chain, test_ghost_pads_forward_setcaps);
tcase_add_test (tc_chain, test_ghost_pads_sink_link_unlink);
tcase_add_test (tc_chain, test_ghost_pads_src_link_unlink);
tcase_add_test (tc_chain, test_ghost_pads_change_when_linked);