From a3cb86522aa8f8b885b70bb70ccde49be716032d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 21 Apr 2004 19:12:51 +0000 Subject: [PATCH] gst/gstpad.c: refuse to link if the link is not possible Original commit message from CVS: * gst/gstpad.c: (gst_pad_link_negotiate): refuse to link if the link is not possible * configure.ac: * testsuite/Makefile.am: * testsuite/negotiation/.cvsignore: * testsuite/negotiation/Makefile.am: * testsuite/negotiation/pad_link.c: (main): add test that checks the above behaviour --- ChangeLog | 11 +++++++++ configure.ac | 1 + gst/gstpad.c | 8 +++---- tests/old/testsuite/Makefile.am | 4 ++-- tests/old/testsuite/negotiation/.gitignore | 2 ++ tests/old/testsuite/negotiation/Makefile.am | 7 ++++++ tests/old/testsuite/negotiation/pad_link.c | 35 +++++++++++++++++++++++++++++ testsuite/Makefile.am | 4 ++-- testsuite/negotiation/.gitignore | 2 ++ testsuite/negotiation/Makefile.am | 7 ++++++ testsuite/negotiation/pad_link.c | 35 +++++++++++++++++++++++++++++ 11 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 tests/old/testsuite/negotiation/.gitignore create mode 100644 tests/old/testsuite/negotiation/Makefile.am create mode 100644 tests/old/testsuite/negotiation/pad_link.c create mode 100644 testsuite/negotiation/.gitignore create mode 100644 testsuite/negotiation/Makefile.am create mode 100644 testsuite/negotiation/pad_link.c diff --git a/ChangeLog b/ChangeLog index 4b5326a..59ada1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-04-21 Benjamin Otte + + * gst/gstpad.c: (gst_pad_link_negotiate): + refuse to link if the link is not possible + * configure.ac: + * testsuite/Makefile.am: + * testsuite/negotiation/.cvsignore: + * testsuite/negotiation/Makefile.am: + * testsuite/negotiation/pad_link.c: (main): + add test that checks the above behaviour + 2004-04-21 Thomas Vander Stichele * docs/gst/gstreamer-sections.txt: diff --git a/configure.ac b/configure.ac index 63be0ca..68192a6 100644 --- a/configure.ac +++ b/configure.ac @@ -662,6 +662,7 @@ testsuite/dynparams/Makefile testsuite/elements/Makefile testsuite/ghostpads/Makefile testsuite/indexers/Makefile +testsuite/negotiation/Makefile testsuite/parse/Makefile testsuite/plugin/Makefile testsuite/refcounting/Makefile diff --git a/gst/gstpad.c b/gst/gstpad.c index a9c76b3..40fd0bc 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1308,10 +1308,6 @@ gst_pad_link_negotiate (GstPadLink * link) GST_DEBUG ("negotiating link from pad %s:%s to pad %s:%s", GST_DEBUG_PAD_NAME (link->srcpad), GST_DEBUG_PAD_NAME (link->sinkpad)); - if (!gst_pad_link_ready_for_negotiation (link)) { - return GST_PAD_LINK_DELAYED; - } - gst_pad_link_intersect (link); if (gst_caps_is_empty (link->caps)) return GST_PAD_LINK_REFUSED; @@ -1320,6 +1316,10 @@ gst_pad_link_negotiate (GstPadLink * link) if (gst_caps_is_empty (link->caps)) return GST_PAD_LINK_REFUSED; + if (!gst_pad_link_ready_for_negotiation (link)) { + return GST_PAD_LINK_DELAYED; + } + return gst_pad_link_call_link_functions (link); } diff --git a/tests/old/testsuite/Makefile.am b/tests/old/testsuite/Makefile.am index 34f801b..74b8493 100644 --- a/tests/old/testsuite/Makefile.am +++ b/tests/old/testsuite/Makefile.am @@ -16,11 +16,11 @@ endif SUBDIRS = bins bytestream cleanup dynparams ghostpads \ caps plugin elements clock refcounting tags threads \ indexers debug $(GST_PARSE_DIRS) $(GST_DEBUG_DIRS) \ - dlopen + dlopen negotiation DIST_SUBDIRS = bins bytestream caps cleanup clock dynparams elements indexers \ plugin refcounting tags threads parse debug ghostpads \ - dlopen + dlopen negotiation tests_pass = test_gst_init tests_fail = diff --git a/tests/old/testsuite/negotiation/.gitignore b/tests/old/testsuite/negotiation/.gitignore new file mode 100644 index 0000000..7972511 --- /dev/null +++ b/tests/old/testsuite/negotiation/.gitignore @@ -0,0 +1,2 @@ +pad_link + diff --git a/tests/old/testsuite/negotiation/Makefile.am b/tests/old/testsuite/negotiation/Makefile.am new file mode 100644 index 0000000..daa2617 --- /dev/null +++ b/tests/old/testsuite/negotiation/Makefile.am @@ -0,0 +1,7 @@ +include ../Rules + +tests_pass = pad_link +tests_fail = +tests_ignore = + + diff --git a/tests/old/testsuite/negotiation/pad_link.c b/tests/old/testsuite/negotiation/pad_link.c new file mode 100644 index 0000000..553686f --- /dev/null +++ b/tests/old/testsuite/negotiation/pad_link.c @@ -0,0 +1,35 @@ +#include + +/* this test checks that gst_pad_link takes into account all available + * information when trying to link two pads. + * Because identity proxies caps, the caps in the first and second link + * must be compatible for this pipeline to work. + * Since they are not, the second linkig attempt should fail. + */ + +gint +main (int argc, gchar ** argv) +{ + GstElement *src, *identity, *sink; + GstCaps *one, *two; + + gst_init (&argc, &argv); + + /* create incompatible caps */ + src = gst_element_factory_make ("fakesrc", NULL); + g_assert (src); + identity = gst_element_factory_make ("identity", NULL); + g_assert (identity); + sink = gst_element_factory_make ("fakesink", NULL); + g_assert (sink); + + one = gst_caps_from_string ("some/mime"); + two = gst_caps_from_string ("other/mime"); + + g_assert (GST_PAD_LINK_SUCCESSFUL (gst_pad_link_filtered (gst_element_get_pad + (src, "src"), gst_element_get_pad (identity, "sink"), one))); + g_assert (!GST_PAD_LINK_SUCCESSFUL (gst_pad_link_filtered (gst_element_get_pad + (identity, "src"), gst_element_get_pad (sink, "sink"), two))); + + return 0; +} diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 34f801b..74b8493 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -16,11 +16,11 @@ endif SUBDIRS = bins bytestream cleanup dynparams ghostpads \ caps plugin elements clock refcounting tags threads \ indexers debug $(GST_PARSE_DIRS) $(GST_DEBUG_DIRS) \ - dlopen + dlopen negotiation DIST_SUBDIRS = bins bytestream caps cleanup clock dynparams elements indexers \ plugin refcounting tags threads parse debug ghostpads \ - dlopen + dlopen negotiation tests_pass = test_gst_init tests_fail = diff --git a/testsuite/negotiation/.gitignore b/testsuite/negotiation/.gitignore new file mode 100644 index 0000000..7972511 --- /dev/null +++ b/testsuite/negotiation/.gitignore @@ -0,0 +1,2 @@ +pad_link + diff --git a/testsuite/negotiation/Makefile.am b/testsuite/negotiation/Makefile.am new file mode 100644 index 0000000..daa2617 --- /dev/null +++ b/testsuite/negotiation/Makefile.am @@ -0,0 +1,7 @@ +include ../Rules + +tests_pass = pad_link +tests_fail = +tests_ignore = + + diff --git a/testsuite/negotiation/pad_link.c b/testsuite/negotiation/pad_link.c new file mode 100644 index 0000000..553686f --- /dev/null +++ b/testsuite/negotiation/pad_link.c @@ -0,0 +1,35 @@ +#include + +/* this test checks that gst_pad_link takes into account all available + * information when trying to link two pads. + * Because identity proxies caps, the caps in the first and second link + * must be compatible for this pipeline to work. + * Since they are not, the second linkig attempt should fail. + */ + +gint +main (int argc, gchar ** argv) +{ + GstElement *src, *identity, *sink; + GstCaps *one, *two; + + gst_init (&argc, &argv); + + /* create incompatible caps */ + src = gst_element_factory_make ("fakesrc", NULL); + g_assert (src); + identity = gst_element_factory_make ("identity", NULL); + g_assert (identity); + sink = gst_element_factory_make ("fakesink", NULL); + g_assert (sink); + + one = gst_caps_from_string ("some/mime"); + two = gst_caps_from_string ("other/mime"); + + g_assert (GST_PAD_LINK_SUCCESSFUL (gst_pad_link_filtered (gst_element_get_pad + (src, "src"), gst_element_get_pad (identity, "sink"), one))); + g_assert (!GST_PAD_LINK_SUCCESSFUL (gst_pad_link_filtered (gst_element_get_pad + (identity, "src"), gst_element_get_pad (sink, "sink"), two))); + + return 0; +} -- 2.7.4