diff --git a/ChangeLog b/ChangeLog index 495f07af41..bdf99aa9f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,56 @@ +2005-08-20 Thomas Vander Stichele + + * check/elements/.cvsignore: + * check/elements/gstfakesrc.c: + rename to name of element + * check/elements/identity.c: (chain_func), (event_func), + (setup_identity), (cleanup_identity), (GST_START_TEST), + (identity_suite), (main): + add a test for identity + * check/Makefile.am: + * pkgconfig/Makefile.am: + * pkgconfig/gstreamer-check.pc.in: + * pkgconfig/gstreamer-check-uninstalled.pc.in: + * gst/check: + * gst/Makefile.am: + * configure.ac: + move the check stuff to a library that gets installed + * check/gst-libs/controller.c: (GST_START_TEST): + * check/gst-libs/gdp.c: + * check/gst/gst.c: (GST_START_TEST): + * check/gst/gstbin.c: + * check/gst/gstbuffer.c: (GST_START_TEST), (gst_test_suite): + * check/gst/gstbus.c: + * check/gst/gstcaps.c: (GST_START_TEST): + * check/gst/gstelement.c: + * check/gst/gstghostpad.c: + * check/gst/gstiterator.c: + * check/gst/gstmessage.c: + * check/gst/gstminiobject.c: (thread_ref), (GST_START_TEST): + * check/gst/gstobject.c: + * check/gst/gstpad.c: (GST_START_TEST): + * check/gst/gststructure.c: (GST_START_TEST): + * check/gst/gstsystemclock.c: (GST_START_TEST), + (gst_systemclock_suite): + * check/gst/gsttag.c: (gst_tag_suite): + * check/gst/gstvalue.c: + * check/pipelines/cleanup.c: + * check/pipelines/simple_launch_lines.c: + * check/states/sinks.c: + change include statement + + * docs/gst/gstreamer-sections.txt: + * docs/gst/tmpl/gstpad.sgml: + document more pad stuff + * gst/gstminiobject.c: (gst_mini_object_ref), + (gst_mini_object_unref): + debug refcounting + 2005-08-19 Stefan Kost * docs/gst/tmpl/gst.sgml: * gst/gst.c: - eliminate another tmpl file, fix spelling in the long-description + eliminate another tmpl file, fix spelling in the long-description 2005-08-18 Jan Schmidt @@ -46,7 +94,7 @@ * check/gst/gstevents.c: (GST_START_TEST), (event_probe), (test_event), (timediff), (gstevents_suite): - Fix error message output so I might be able to tell why the + Fix error message output so I might be able to tell why the test works here but fails on the build farm. 2005-08-18 Jan Schmidt diff --git a/check/Makefile.am b/check/Makefile.am index d4fbc05882..982a21bed0 100644 --- a/check/Makefile.am +++ b/check/Makefile.am @@ -49,6 +49,7 @@ TESTS = $(top_builddir)/tools/gst-register \ gst/gsttag \ gst/gstvalue \ elements/gstfakesrc \ + elements/identity \ pipelines/simple_launch_lines \ pipelines/cleanup \ states/sinks \ @@ -57,14 +58,11 @@ TESTS = $(top_builddir)/tools/gst-register \ check_PROGRAMS = $(TESTS) -noinst_LTLIBRARIES = libgstcheck.la +noinst_HEADERS = gst/capslist.h -libgstcheck_la_SOURCES = gstcheck.c -libgstcheck_la_LIBADD = $(GST_OBJ_LIBS) -noinst_HEADERS = gstcheck.h gst/capslist.h - -AM_CFLAGS = $(GST_OBJ_CFLAGS) $(CHECK_CFLAGS) -LDADD = $(GST_OBJ_LIBS) $(CHECK_LIBS) libgstcheck.la +AM_CFLAGS = $(GST_OBJ_CFLAGS) +LDADD = $(GST_OBJ_LIBS) \ + $(top_builddir)/gst/check/libgstcheck-@GST_MAJORMINOR@.la gst_libs_gdp_SOURCES = \ gst-libs/gdp.c \ @@ -72,7 +70,8 @@ gst_libs_gdp_SOURCES = \ # remove GST_ENABLE_NEW when dataprotocol has been declared API-stable gst_libs_gdp_CFLAGS = $(AM_CFLAGS) -DGST_ENABLE_NEW -gst_libs_controller_LDADD = $(GST_OBJ_LIBS) $(CHECK_LIBS) libgstcheck.la \ +gst_libs_controller_LDADD = $(GST_OBJ_LIBS) \ + $(top_builddir)/gst/check/libgstcheck-@GST_MAJORMINOR@.la \ $(top_builddir)/libs/gst/controller/libgstcontroller-@GST_MAJORMINOR@.la # valgrind testing diff --git a/check/elements/.gitignore b/check/elements/.gitignore index a10e4f5188..3bac562993 100644 --- a/check/elements/.gitignore +++ b/check/elements/.gitignore @@ -1,2 +1,3 @@ .dirstamp -gstfakesrc +fakesrc +identity diff --git a/check/elements/gstfakesrc.c b/check/elements/fakesrc.c similarity index 99% rename from check/elements/gstfakesrc.c rename to check/elements/fakesrc.c index e121684e1f..f5328cc376 100644 --- a/check/elements/gstfakesrc.c +++ b/check/elements/fakesrc.c @@ -22,7 +22,7 @@ #include -#include "../gstcheck.h" +#include GList *buffers = NULL; gboolean have_eos = FALSE; diff --git a/check/elements/identity.c b/check/elements/identity.c new file mode 100644 index 0000000000..3da0ce16b2 --- /dev/null +++ b/check/elements/identity.c @@ -0,0 +1,211 @@ +/* GStreamer + * + * unit test for identity + * + * Copyright (C) <2005> Thomas Vander Stichele + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include + +GList *buffers = NULL; +gboolean have_eos = FALSE; + +/* For ease of programming we use globals to keep refs for our floating + * src and sink pads we create; otherwise we always have to do get_pad, + * get_peer, and then remove references in every test function */ +GstPad *mysrcpad, *mysinkpad; + + +static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); +static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + +GstFlowReturn +chain_func (GstPad * pad, GstBuffer * buffer) +{ + GST_DEBUG ("chain_func: received buffer %p", buffer); + buffers = g_list_append (buffers, buffer); + + return GST_FLOW_OK; +} + +gboolean +event_func (GstPad * pad, GstEvent * event) +{ + if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) { + /* we take the lock here because it's good practice to so, even though + * no buffers will be pushed anymore anyway */ + GST_STREAM_LOCK (pad); + have_eos = TRUE; + GST_STREAM_UNLOCK (pad); + gst_event_unref (event); + return TRUE; + } + + gst_event_unref (event); + return FALSE; +} + +GstElement * +setup_identity () +{ + GstElement *identity; + GstPad *srcpad, *sinkpad; + + GST_DEBUG ("setup_identity"); + + identity = gst_element_factory_make ("identity", "identity"); + fail_if (identity == NULL, "Could not create a identity"); + + /* sending pad */ + mysrcpad = + gst_pad_new_from_template (gst_static_pad_template_get (&srctemplate), + "src"); + fail_if (mysrcpad == NULL, "Could not create a mysrcpad"); + ASSERT_OBJECT_REFCOUNT (mysrcpad, "mysrcpad", 1); + + sinkpad = gst_element_get_pad (identity, "sink"); + fail_if (sinkpad == NULL, "Could not get source pad from identity"); + ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2); + gst_pad_set_caps (mysrcpad, NULL); + fail_unless (gst_pad_link (mysrcpad, sinkpad) == GST_PAD_LINK_OK, + "Could not link source and identity sink pads"); + gst_object_unref (sinkpad); /* because we got it higher up */ + ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 1); + + /* receiving pad */ + mysinkpad = + gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate), + "sink"); + fail_if (mysinkpad == NULL, "Could not create a mysinkpad"); + + srcpad = gst_element_get_pad (identity, "src"); + fail_if (srcpad == NULL, "Could not get source pad from identity"); + gst_pad_set_caps (mysinkpad, NULL); + gst_pad_set_chain_function (mysinkpad, chain_func); + gst_pad_set_event_function (mysinkpad, event_func); + + fail_unless (gst_pad_link (srcpad, mysinkpad) == GST_PAD_LINK_OK, + "Could not link identity source and mysink pads"); + gst_object_unref (srcpad); /* because we got it higher up */ + ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1); + + return identity; +} + +void +cleanup_identity (GstElement * identity) +{ + GstPad *srcpad, *sinkpad; + + GST_DEBUG ("cleanup_identity"); + + fail_unless (gst_element_set_state (identity, GST_STATE_NULL) == + GST_STATE_SUCCESS, "could not set to null"); + ASSERT_OBJECT_REFCOUNT (identity, "identity", 1); + + /* clean up floating src pad */ + sinkpad = gst_element_get_pad (identity, "sink"); + ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2); + + gst_pad_unlink (mysrcpad, sinkpad); + + /* pad refs held by both creator and this function (through _get) */ + ASSERT_OBJECT_REFCOUNT (mysrcpad, "srcpad", 1); + gst_object_unref (mysrcpad); + mysrcpad = NULL; + + ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2); + gst_object_unref (sinkpad); + /* one more ref is held by identity itself */ + + /* clean up floating sink pad */ + srcpad = gst_element_get_pad (identity, "src"); + gst_pad_unlink (srcpad, mysinkpad); + + /* pad refs held by both creator and this function (through _get) */ + ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2); + gst_object_unref (srcpad); + /* one more ref is held by identity itself */ + + ASSERT_OBJECT_REFCOUNT (mysinkpad, "mysinkpad", 1); + gst_object_unref (mysinkpad); + mysinkpad = NULL; + + ASSERT_OBJECT_REFCOUNT (identity, "identity", 1); + gst_object_unref (identity); +} + +GST_START_TEST (test_one_buffer) +{ + GstElement *identity; + GstBuffer *buffer; + + identity = setup_identity (); + fail_unless (gst_element_set_state (identity, + GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing"); + + buffer = gst_buffer_new_and_alloc (4); + ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); + memcpy (GST_BUFFER_DATA (buffer), "data", 4); + /* pushing gives away my reference ... */ + gst_pad_push (mysrcpad, buffer); + /* ... but it ends up being collected on the global buffer list */ + ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); + + /* cleanup */ + cleanup_identity (identity); +} + +GST_END_TEST; + +Suite * +identity_suite (void) +{ + Suite *s = suite_create ("identity"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_one_buffer); + + return s; +} + +int +main (int argc, char **argv) +{ + int nf; + + Suite *s = identity_suite (); + SRunner *sr = srunner_create (s); + + gst_check_init (&argc, &argv); + + srunner_run_all (sr, CK_NORMAL); + nf = srunner_ntests_failed (sr); + srunner_free (sr); + + return nf; +} diff --git a/check/gst-libs/controller.c b/check/gst-libs/controller.c index dc1e100b80..23d0a0070c 100644 --- a/check/gst-libs/controller.c +++ b/check/gst-libs/controller.c @@ -21,7 +21,7 @@ */ #include "config.h" -#include "../gstcheck.h" +#include #include /* LOCAL TEST ELEMENT */ diff --git a/check/gst-libs/gdp.c b/check/gst-libs/gdp.c index 7a44741b13..69e74e5f4a 100644 --- a/check/gst-libs/gdp.c +++ b/check/gst-libs/gdp.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include #include #include "libs/gst/dataprotocol/dp-private.h" /* private header */ diff --git a/check/gst/gst.c b/check/gst/gst.c index 11ae64a7d9..993c6330c8 100644 --- a/check/gst/gst.c +++ b/check/gst/gst.c @@ -19,7 +19,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_init) { diff --git a/check/gst/gstbin.c b/check/gst/gstbin.c index bf41dc0f8e..61ae0d25cc 100644 --- a/check/gst/gstbin.c +++ b/check/gst/gstbin.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include static void pop_messages (GstBus * bus, int count) diff --git a/check/gst/gstbuffer.c b/check/gst/gstbuffer.c index 801a6096ac..57912147f0 100644 --- a/check/gst/gstbuffer.c +++ b/check/gst/gstbuffer.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_caps) { diff --git a/check/gst/gstbus.c b/check/gst/gstbus.c index f1677ed455..54ea722d3b 100644 --- a/check/gst/gstbus.c +++ b/check/gst/gstbus.c @@ -20,7 +20,7 @@ */ -#include "../gstcheck.h" +#include static GstBus *test_bus = NULL; diff --git a/check/gst/gstcaps.c b/check/gst/gstcaps.c index df5da49613..9141fceb8c 100644 --- a/check/gst/gstcaps.c +++ b/check/gst/gstcaps.c @@ -21,7 +21,7 @@ */ -#include "../gstcheck.h" +#include #include "capslist.h" GST_START_TEST (test_from_string) diff --git a/check/gst/gstelement.c b/check/gst/gstelement.c index 27bd84e010..aeff42d26d 100644 --- a/check/gst/gstelement.c +++ b/check/gst/gstelement.c @@ -19,7 +19,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_add_remove_pad) { diff --git a/check/gst/gstghostpad.c b/check/gst/gstghostpad.c index 274148337f..455dd1f464 100644 --- a/check/gst/gstghostpad.c +++ b/check/gst/gstghostpad.c @@ -19,7 +19,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include static void assert_gstrefcount (gpointer p, gint i) diff --git a/check/gst/gstiterator.c b/check/gst/gstiterator.c index 01378fc23b..ab640040c9 100644 --- a/check/gst/gstiterator.c +++ b/check/gst/gstiterator.c @@ -20,7 +20,7 @@ */ -#include "../gstcheck.h" +#include static GList * diff --git a/check/gst/gstmessage.c b/check/gst/gstmessage.c index 1d6c0c5eb6..0cfad06e5a 100644 --- a/check/gst/gstmessage.c +++ b/check/gst/gstmessage.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include static GQuark domain; diff --git a/check/gst/gstminiobject.c b/check/gst/gstminiobject.c index 7513f34747..c7e61ef841 100644 --- a/check/gst/gstminiobject.c +++ b/check/gst/gstminiobject.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_copy) { diff --git a/check/gst/gstobject.c b/check/gst/gstobject.c index a7dccb36a1..5d8a94f576 100644 --- a/check/gst/gstobject.c +++ b/check/gst/gstobject.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include /* Create a fake subclass diff --git a/check/gst/gstpad.c b/check/gst/gstpad.c index 5283c20805..8a467210d1 100644 --- a/check/gst/gstpad.c +++ b/check/gst/gstpad.c @@ -19,7 +19,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_link) { diff --git a/check/gst/gststructure.c b/check/gst/gststructure.c index cf9eeeb27a..47fc72ad45 100644 --- a/check/gst/gststructure.c +++ b/check/gst/gststructure.c @@ -20,7 +20,7 @@ */ -#include "../gstcheck.h" +#include GST_START_TEST (test_from_string_int) diff --git a/check/gst/gstsystemclock.c b/check/gst/gstsystemclock.c index a20e98f243..f9a6a35136 100644 --- a/check/gst/gstsystemclock.c +++ b/check/gst/gstsystemclock.c @@ -19,7 +19,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_signedness) { diff --git a/check/gst/gsttag.c b/check/gst/gsttag.c index 1b3397115d..a91315db90 100644 --- a/check/gst/gsttag.c +++ b/check/gst/gsttag.c @@ -18,7 +18,7 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "../gstcheck.h" +#include #include diff --git a/check/gst/gstvalue.c b/check/gst/gstvalue.c index 4dc3dae289..b492d12db0 100644 --- a/check/gst/gstvalue.c +++ b/check/gst/gstvalue.c @@ -21,7 +21,7 @@ */ -#include "../gstcheck.h" +#include GST_START_TEST (test_deserialize_buffer) diff --git a/check/pipelines/cleanup.c b/check/pipelines/cleanup.c index 7b3a3b4c0f..687244739c 100644 --- a/check/pipelines/cleanup.c +++ b/check/pipelines/cleanup.c @@ -20,7 +20,7 @@ */ -#include "../gstcheck.h" +#include static GstElement * diff --git a/check/pipelines/simple_launch_lines.c b/check/pipelines/simple_launch_lines.c index d29c88efb3..618d3a5577 100644 --- a/check/pipelines/simple_launch_lines.c +++ b/check/pipelines/simple_launch_lines.c @@ -20,7 +20,7 @@ */ -#include "../gstcheck.h" +#include static GstElement * diff --git a/check/states/sinks.c b/check/states/sinks.c index ae295be5d3..84bd9fbecf 100644 --- a/check/states/sinks.c +++ b/check/states/sinks.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include /* a sink should go ASYNC to PAUSE. forcing PLAYING is possible */ GST_START_TEST (test_sink) diff --git a/configure.ac b/configure.ac index be04d2ba94..4d3e2812b5 100644 --- a/configure.ac +++ b/configure.ac @@ -624,6 +624,7 @@ gst/Makefile gst/gstconfig.h gst/gstversion.h gst/base/Makefile +gst/check/Makefile gst/indexers/Makefile gst/elements/Makefile gst/parse/Makefile @@ -694,6 +695,8 @@ pkgconfig/gstreamer.pc pkgconfig/gstreamer-uninstalled.pc pkgconfig/gstreamer-base.pc pkgconfig/gstreamer-base-uninstalled.pc +pkgconfig/gstreamer-check.pc +pkgconfig/gstreamer-check-uninstalled.pc pkgconfig/gstreamer-controller.pc pkgconfig/gstreamer-controller-uninstalled.pc pkgconfig/gstreamer-dataprotocol.pc diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 1efc0839f8..5c4f000c23 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -844,72 +844,111 @@ xmlNodePtr GstPad GST_PAD_LINK_FAILED GST_PAD_LINK_SUCCESSFUL +GstPadActivateFunction +GstPadActivateModeFunction +GstPadBlockCallback GstPadChainFunction GstPadEventFunction +GstPadCheckGetRangeFunction +GstPadGetRangeFunction GstPadQueryFunction GstPadIntLinkFunction GstPadQueryTypeFunction GstPadLinkFunction GstPadUnlinkFunction +GstPadAcceptCapsFunction +GstPadFixateCapsFunction GstPadGetCapsFunction +GstPadSetCapsFunction GstPadBufferAllocFunction GstPadDispatcherFunction GstPadDirection GstPadFlags GstPadLinkReturn GstPadPresence -GST_PAD_NAME -GST_PAD_PARENT -GST_PAD_ELEMENT_PRIVATE -GST_PAD_PAD_TEMPLATE -GST_PAD_DIRECTION -GST_PAD_CAPS -GST_PAD_PEER -GST_PAD_IS_LINKED -GST_PAD_IS_USABLE -GST_PAD_IS_SRC -GST_PAD_IS_SINK + gst_pad_new gst_pad_new_from_template + gst_pad_get_name gst_pad_get_direction +gst_pad_get_parent +gst_pad_get_parent_element + gst_pad_set_active gst_pad_is_active +gst_pad_set_blocked +gst_pad_set_blocked_async +gst_pad_is_blocked gst_pad_set_element_private gst_pad_get_element_private -gst_pad_get_parent gst_pad_get_pad_template gst_pad_set_bufferalloc_function gst_pad_alloc_buffer gst_pad_set_chain_function +gst_pad_chain +gst_pad_set_checkgetrange_function +gst_pad_set_getrange_function +gst_pad_get_range gst_pad_set_event_function -gst_pad_set_link_function -gst_pad_can_link gst_pad_set_unlink_function +gst_pad_set_activate_function +gst_pad_set_activatepull_function + +gst_pad_start_task +gst_pad_pause_task +gst_pad_stop_task + gst_pad_link gst_pad_unlink gst_pad_is_linked -gst_pad_get_peer +gst_pad_set_link_function +gst_pad_can_link + +gst_pad_accept_caps gst_pad_get_negotiated_caps gst_pad_get_caps +gst_pad_set_caps gst_pad_get_pad_template_caps +gst_pad_set_acceptcaps_function gst_pad_set_getcaps_function +gst_pad_set_setcaps_function gst_pad_proxy_getcaps +gst_pad_proxy_setcaps gst_pad_get_allowed_caps +gst_pad_get_fixed_caps_func +gst_pad_get_peer +gst_pad_peer_get_caps +gst_pad_peer_accept_caps +gst_pad_use_fixed_caps +gst_pad_fixate_caps +gst_pad_set_fixatecaps_function + +gst_pad_set_activatepush_function gst_pad_push +gst_pad_push_event +gst_pad_check_pull_range +gst_pad_pull_range +gst_pad_activate_pull +gst_pad_activate_push gst_pad_send_event gst_pad_event_default + gst_pad_set_query_function gst_pad_set_query_type_function gst_pad_get_query_types gst_pad_get_query_types_default gst_pad_query gst_pad_query_default +gst_pad_query_position +gst_pad_query_convert + gst_pad_set_internal_link_function gst_pad_get_internal_links gst_pad_get_internal_links_default gst_pad_dispatcher gst_pad_load_and_link + gst_pad_add_data_probe gst_pad_add_buffer_probe gst_pad_add_event_probe @@ -927,12 +966,61 @@ GST_TYPE_PAD_DIRECTION GST_TYPE_PAD_FLAGS GST_TYPE_PAD_LINK_RETURN GST_TYPE_PAD_PRESENCE + gst_pad_get_type gst_pad_direction_get_type gst_pad_flags_get_type gst_pad_link_return_get_type gst_pad_presence_get_type + +GST_PAD_NAME +GST_PAD_PARENT +GST_PAD_ELEMENT_PRIVATE +GST_PAD_PAD_TEMPLATE +GST_PAD_DIRECTION +GST_PAD_CAPS +GST_PAD_PEER +GST_PAD_IS_LINKED +GST_PAD_IS_USABLE +GST_PAD_IS_SRC +GST_PAD_IS_SINK + +GST_PAD_IS_IN_GETCAPS +GST_PAD_MODE_ACTIVATE +GST_PAD_BLOCK_GET_COND +GST_PAD_BLOCK_SIGNAL +GST_PAD_BLOCK_WAIT +GST_PAD_CAST +GST_PAD_ACTIVATE_MODE +GST_PAD_DO_BUFFER_SIGNALS +GST_PAD_DO_EVENT_SIGNALS +GST_PAD_IS_BLOCKED +GST_PAD_IS_IN_SETCAPS +GST_PAD_SET_FLUSHING +GST_PAD_TASK +GST_PAD_UNSET_FLUSHING + + +GST_PAD_ACCEPTCAPSFUNC +GST_PAD_ACTIVATEFUNC +GST_PAD_ACTIVATEPULLFUNC +GST_PAD_ACTIVATEPUSHFUNC +GST_PAD_BUFFERALLOCFUNC +GST_PAD_CHAINFUNC +GST_PAD_CHECKGETRANGEFUNC +GST_PAD_EVENTFUNC +GST_PAD_FIXATECAPSFUNC +GST_PAD_GETCAPSFUNC +GST_PAD_GETRANGEFUNC +GST_PAD_INTLINKFUNC +GST_PAD_IS_FLUSHING +GST_PAD_LINKFUNC +GST_PAD_QUERYFUNC +GST_PAD_QUERYTYPEFUNC +GST_PAD_SETCAPSFUNC +GST_PAD_UNLINKFUNC +
diff --git a/docs/gst/tmpl/gstpad.sgml b/docs/gst/tmpl/gstpad.sgml index fa5a64d5b2..1427afa62e 100644 --- a/docs/gst/tmpl/gstpad.sgml +++ b/docs/gst/tmpl/gstpad.sgml @@ -161,6 +161,35 @@ successfull negotiation step (OK/DONE). @ret: the #GstPadLinkReturn value + + + + + +@pad: +@Returns: + + + + + + + +@pad: +@active: +@Returns: + + + + + + + +@pad: +@blocked: +@user_data: + + A function that will be called when chaining buffers. @@ -184,6 +213,27 @@ Function signature to handle an event for the pad. @Returns: TRUE if the pad could handle the event. + + + + + +@pad: +@Returns: + + + + + + + +@pad: +@offset: +@length: +@buffer: +@Returns: + + The signature of the query function. @@ -238,6 +288,25 @@ Function signature to handle a new link on the pad. @pad: + + + + + +@pad: +@caps: +@Returns: + + + + + + + +@pad: +@caps: + + Returns a copy of the capabilities of the specified pad. By default this @@ -251,6 +320,16 @@ be overridden. @caps: the peer's #GstCaps, can be used to filter the capabilities. + + + + + +@pad: +@caps: +@Returns: + + @@ -318,103 +397,6 @@ Indicates when this pad will become available. @GST_PAD_REQUEST: the pad is only available on request with gst_element_request_pad_by_name() or gst_element_request_compatible_pad(). - - -Gets the name of the pad. - - -@pad: a #GstPad to get the name of. -@Returns: the pad's name. - - - - -Gets the parent element of this pad. - - -@pad: a #GstPad to get the parent of. -@Returns: the parent #GstElement of this pad. - - - - -Gets the private data set by the element that owns the pad. - - -@pad: a #GstPad to get the private data of. -#Returns: a gpointer to the private data. - - - - -Gets the pad template that was used to create this pad. - - -@pad: a #GstPad to get the pad template of. -#Returns: the #GstPadTemplate used to create the pad, or NULL if none was -used. - - - - -Gets the pad's direction. - - -@pad: a #GstPad to get the direction of. -@Returns: the #GstPadDirection of the pad. - - - - -Gets the capabilities of a pad. - - -@pad: a #GstPad to get the capabilities of. -@Returns: the #GstCaps of the pad. - - - - -Gets the peer pad of this pad. The peer pad is the pad on to which the parent -element is linked through this pad. - - -@pad: a #GstPad to get the peer pad of. -@Returns: the peer #GstPad. - - - - -Checks if the pad is linked. - - -@pad: a #GstPad to check. - - - - -Checks if a pad is usable. A usable pad is both linked and active. - - -@pad: a #GstPad to check - - - - -Checks if the pad is a source pad. - - -@pad: a #GstPad to check. - - - - -Checks if the pad is a sink pad. - - -@pad: a #GstPad to check. - - @@ -453,6 +435,24 @@ Checks if the pad is a sink pad. @Returns: + + + + + +@pad: +@Returns: + + + + + + + +@pad: +@Returns: + + @@ -474,6 +474,37 @@ Checks if the pad is a sink pad. @Returns: + + + + + +@pad: +@blocked: +@Returns: + + + + + + + +@pad: +@blocked: +@callback: +@user_data: +@Returns: + + + + + + + +@pad: +@Returns: + + @@ -492,15 +523,6 @@ Checks if the pad is a sink pad. @Returns: - - - - - -@pad: -@Returns: - - @@ -543,6 +565,46 @@ Checks if the pad is a sink pad. @chain: + + + + + +@pad: +@buffer: +@Returns: + + + + + + + +@pad: +@check: + + + + + + + +@pad: +@get: + + + + + + + +@pad: +@offset: +@size: +@buffer: +@Returns: + + @@ -552,25 +614,6 @@ Checks if the pad is a sink pad. @event: - - - - - -@pad: -@link: - - - - - - - -@srcpad: -@sinkpad: -@Returns: - - @@ -580,6 +623,53 @@ Checks if the pad is a sink pad. @unlink: + + + + + +@pad: +@activate: + + + + + + + +@pad: +@activatepull: + + + + + + + +@pad: +@func: +@data: +@Returns: + + + + + + + +@pad: +@Returns: + + + + + + + +@pad: +@Returns: + + @@ -609,12 +699,32 @@ Checks if the pad is a sink pad. @Returns: - + @pad: +@link: + + + + + + + +@srcpad: +@sinkpad: +@Returns: + + + + + + + +@pad: +@caps: @Returns: @@ -636,6 +746,16 @@ Checks if the pad is a sink pad. @Returns: + + + + + +@pad: +@caps: +@Returns: + + @@ -645,6 +765,15 @@ Checks if the pad is a sink pad. @Returns: + + + + + +@pad: +@acceptcaps: + + @@ -654,6 +783,15 @@ Checks if the pad is a sink pad. @getcaps: + + + + + +@pad: +@setcaps: + + @@ -663,6 +801,16 @@ Checks if the pad is a sink pad. @Returns: + + + + + +@pad: +@caps: +@Returns: + + @@ -674,6 +822,78 @@ Checks if the pad is a sink pad. @pad: + + + + + +@pad: +@Returns: + + + + + + + +@pad: +@Returns: + + + + + + + +@pad: +@Returns: + + + + + + + +@pad: +@caps: +@Returns: + + + + + + + +@pad: + + + + + + + +@pad: +@caps: + + + + + + + +@pad: +@fixatecaps: + + + + + + + +@pad: +@activatepush: + + @@ -687,6 +907,57 @@ Checks if the pad is a sink pad. @buf: + + + + + +@pad: +@event: +@Returns: + + + + + + + +@pad: +@Returns: + + + + + + + +@pad: +@offset: +@size: +@buffer: +@Returns: + + + + + + + +@pad: +@active: +@Returns: + + + + + + + +@pad: +@active: +@Returns: + + @@ -771,6 +1042,31 @@ Checks if the pad is a sink pad. @value: + + + + + +@pad: +@format: +@cur: +@end: +@Returns: + + + + + + + +@pad: +@src_format: +@src_val: +@dest_fmt: +@dest_val: +@Returns: + + diff --git a/gst/Makefile.am b/gst/Makefile.am index 08f5b40d71..7199a2a8b0 100644 --- a/gst/Makefile.am +++ b/gst/Makefile.am @@ -1,7 +1,10 @@ lib_LTLIBRARIES = libgstreamer-@GST_MAJORMINOR@.la -noinst_LTLIBRARIES = -#GST_INSTRUMENT_FLAGS = -finstrument-functions -DGST_ENABLE_FUNC_INSTRUMENTATION +if HAVE_CHECK +SUBDIRS_CHECK = check +else +SUBDIRS_CHECK = +endif if GST_DISABLE_LOADSAVE GST_LOADSAVE_SRC = @@ -11,11 +14,11 @@ endif if GST_DISABLE_PARSE GST_PARSE_SRC = -GST_PARSE_DIRS = +SUBDIRS_PARSE = GST_PARSE_LA = else GST_PARSE_SRC = gstparse.c -GST_PARSE_DIRS = parse +SUBDIRS_PARSE = parse GST_PARSE_LA = parse/libgstparse.la endif @@ -27,11 +30,11 @@ endif if GST_DISABLE_REGISTRY GST_REGISTRY_SRC = -GST_REGISTRY_DIRS = +SUBDIRS_REGISTRY = GST_REGISTRY_LA = else GST_REGISTRY_SRC = gstregistry.c -GST_REGISTRY_DIRS = registries +SUBDIRS_REGISTRY = registries GST_REGISTRY_LA = registries/libgstxmlregistry.la endif @@ -43,10 +46,10 @@ endif if GST_DISABLE_INDEX GST_INDEX_SRC = -GST_INDEX_DIRS = +SUBDIRS_INDEX = else GST_INDEX_SRC = gstindex.c -GST_INDEX_DIRS = indexers +SUBDIRS_INDEX = indexers endif if GST_DISABLE_PLUGIN @@ -61,8 +64,8 @@ else GST_URI_SRC = gsturi.c endif -SUBDIRS = $(GST_PARSE_DIRS) $(GST_REGISTRY_DIRS) . base elements $(GST_INDEX_DIRS) -DIST_SUBDIRS = base elements parse registries indexers +SUBDIRS = $(SUBDIRS_PARSE) $(SUBDIRS_REGISTRY) . base elements $(SUBDIRS_INDEX) $(SUBDIRS_CHECK) +DIST_SUBDIRS = base elements parse registries indexers $(SUBDIRS_CHECK) # make variables for all generated source and header files to make the # distinction clear diff --git a/gst/check/Makefile.am b/gst/check/Makefile.am new file mode 100644 index 0000000000..7d67323c44 --- /dev/null +++ b/gst/check/Makefile.am @@ -0,0 +1,17 @@ +lib_LTLIBRARIES = libgstcheck-@GST_MAJORMINOR@.la + +libgstcheck_@GST_MAJORMINOR@_la_DEPENDENCIES = \ + ../libgstreamer-@GST_MAJORMINOR@.la +libgstcheck_@GST_MAJORMINOR@_la_SOURCES = \ + gstcheck.c + +libgstcheck_@GST_MAJORMINOR@_la_CFLAGS = $(GST_OBJ_CFLAGS) $(CHECK_CFLAGS) +libgstcheck_@GST_MAJORMINOR@_la_LIBADD = $(GST_OBJ_LIBS) $(CHECK_LIBS) \ + ../libgstreamer-@GST_MAJORMINOR@.la +libgstcheck_@GST_MAJORMINOR@_la_LDFLAGS = + +libgstcheck_@GST_MAJORMINOR@includedir = \ + $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/check + +libgstcheck_@GST_MAJORMINOR@include_HEADERS = \ + gstcheck.h diff --git a/check/gstcheck.c b/gst/check/gstcheck.c similarity index 100% rename from check/gstcheck.c rename to gst/check/gstcheck.c diff --git a/check/gstcheck.h b/gst/check/gstcheck.h similarity index 100% rename from check/gstcheck.h rename to gst/check/gstcheck.h diff --git a/gst/gstminiobject.c b/gst/gstminiobject.c index 2f89573466..02ba239668 100644 --- a/gst/gstminiobject.c +++ b/gst/gstminiobject.c @@ -23,15 +23,17 @@ #include "config.h" #endif -#ifndef GST_DISABLE_TRACE -#include "gsttrace.h" -#endif - #include "gst/gstminiobject.h" #include "gst/gstinfo.h" #include "gst/gst_private.h" #include +#ifndef GST_DISABLE_TRACE +#include "gsttrace.h" +#endif + +#define DEBUG_REFCOUNT + static void gst_mini_object_base_init (gpointer g_class); static void gst_mini_object_base_finalize (gpointer g_class); static void gst_mini_object_class_init (gpointer g_class, gpointer class_data); @@ -189,12 +191,18 @@ gst_mini_object_ref (GstMiniObject * mini_object) { g_return_val_if_fail (mini_object != NULL, NULL); +#ifdef DEBUG_REFCOUNT + GST_CAT_LOG (GST_CAT_REFCOUNTING, "%p ref %d->%d", + mini_object, + GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object), + GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) + 1); +#endif + g_atomic_int_inc (&mini_object->refcount); return mini_object; } - static void gst_mini_object_free (GstMiniObject * mini_object) { @@ -231,6 +239,13 @@ gst_mini_object_unref (GstMiniObject * mini_object) g_return_if_fail (mini_object != NULL); g_return_if_fail (mini_object->refcount > 0); +#ifdef DEBUG_REFCOUNT + GST_CAT_LOG (GST_CAT_REFCOUNTING, "%p unref %d->%d", + mini_object, + GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object), + GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) - 1); +#endif + if (g_atomic_int_dec_and_test (&mini_object->refcount)) { gst_mini_object_free (mini_object); } diff --git a/libs/gst/check/Makefile.am b/libs/gst/check/Makefile.am new file mode 100644 index 0000000000..7d67323c44 --- /dev/null +++ b/libs/gst/check/Makefile.am @@ -0,0 +1,17 @@ +lib_LTLIBRARIES = libgstcheck-@GST_MAJORMINOR@.la + +libgstcheck_@GST_MAJORMINOR@_la_DEPENDENCIES = \ + ../libgstreamer-@GST_MAJORMINOR@.la +libgstcheck_@GST_MAJORMINOR@_la_SOURCES = \ + gstcheck.c + +libgstcheck_@GST_MAJORMINOR@_la_CFLAGS = $(GST_OBJ_CFLAGS) $(CHECK_CFLAGS) +libgstcheck_@GST_MAJORMINOR@_la_LIBADD = $(GST_OBJ_LIBS) $(CHECK_LIBS) \ + ../libgstreamer-@GST_MAJORMINOR@.la +libgstcheck_@GST_MAJORMINOR@_la_LDFLAGS = + +libgstcheck_@GST_MAJORMINOR@includedir = \ + $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/check + +libgstcheck_@GST_MAJORMINOR@include_HEADERS = \ + gstcheck.h diff --git a/tests/check/gstcheck.c b/libs/gst/check/gstcheck.c similarity index 100% rename from tests/check/gstcheck.c rename to libs/gst/check/gstcheck.c diff --git a/tests/check/gstcheck.h b/libs/gst/check/gstcheck.h similarity index 100% rename from tests/check/gstcheck.h rename to libs/gst/check/gstcheck.h diff --git a/pkgconfig/Makefile.am b/pkgconfig/Makefile.am index 6229990629..69631935bc 100644 --- a/pkgconfig/Makefile.am +++ b/pkgconfig/Makefile.am @@ -1,13 +1,23 @@ ### all of the standard pc files we need to generate +if HAVE_CHECK +CHECK_PC_I = gstreamer-check-@GST_MAJORMINOR@.pc +CHECK_PC_U = gstreamer-check-@GST_MAJORMINOR@-uninstalled.pc +else +CHECK_PC_I = +CHECK_PC_U = +endif + pcfiles = \ gstreamer-@GST_MAJORMINOR@.pc \ gstreamer-base-@GST_MAJORMINOR@.pc \ - gstreamer-controller-@GST_MAJORMINOR@.pc \ + $(CHECK_PC_I) \ + gstreamer-controller-@GST_MAJORMINOR@.pc \ gstreamer-dataprotocol-@GST_MAJORMINOR@.pc pcfiles_uninstalled = \ gstreamer-@GST_MAJORMINOR@-uninstalled.pc \ gstreamer-base-@GST_MAJORMINOR@-uninstalled.pc \ + $(CHECK_PC_U) \ gstreamer-controller-@GST_MAJORMINOR@-uninstalled.pc \ gstreamer-dataprotocol-@GST_MAJORMINOR@-uninstalled.pc @@ -27,7 +37,9 @@ EXTRA_DIST = \ gstreamer-uninstalled.pc.in \ gstreamer-base.pc.in \ gstreamer-base-uninstalled.pc.in \ - gstreamer-controller.pc.in \ + gstreamer-check.pc.in \ + gstreamer-check-uninstalled.pc.in \ + gstreamer-controller.pc.in \ gstreamer-controller-uninstalled.pc.in \ gstreamer-dataprotocol.pc.in \ gstreamer-dataprotocol-uninstalled.pc.in diff --git a/pkgconfig/gstreamer-check-uninstalled.pc.in b/pkgconfig/gstreamer-check-uninstalled.pc.in new file mode 100644 index 0000000000..5707af0df7 --- /dev/null +++ b/pkgconfig/gstreamer-check-uninstalled.pc.in @@ -0,0 +1,13 @@ +# the standard variables don't make sense for an uninstalled copy +prefix= +exec_prefix= +libdir=${pcfiledir}/../gst/check +includedir=${pcfiledir}/.. + +Name: GStreamer check unittesting, uninstalled +Description: Unit testing helper library for GStreamer modules +Requires: gstreamer-@GST_MAJORMINOR@ = @VERSION@ +Version: @VERSION@ + +Libs: ${libdir}/libgstcheck-@GST_MAJORMINOR@.la +Cflags: -I${includedir} diff --git a/pkgconfig/gstreamer-check.pc.in b/pkgconfig/gstreamer-check.pc.in new file mode 100644 index 0000000000..d1bda6d687 --- /dev/null +++ b/pkgconfig/gstreamer-check.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@/gstreamer-@GST_MAJORMINOR@ + +Name: GStreamer check unittesting +Description: Unit testing helper library for GStreamer modules +Requires: gstreamer-@GST_MAJORMINOR@ +Version: @VERSION@ +Libs: -L${libdir} -lgstcheck-@GST_MAJORMINOR@ +Cflags: -I${includedir} diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index d4fbc05882..982a21bed0 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -49,6 +49,7 @@ TESTS = $(top_builddir)/tools/gst-register \ gst/gsttag \ gst/gstvalue \ elements/gstfakesrc \ + elements/identity \ pipelines/simple_launch_lines \ pipelines/cleanup \ states/sinks \ @@ -57,14 +58,11 @@ TESTS = $(top_builddir)/tools/gst-register \ check_PROGRAMS = $(TESTS) -noinst_LTLIBRARIES = libgstcheck.la +noinst_HEADERS = gst/capslist.h -libgstcheck_la_SOURCES = gstcheck.c -libgstcheck_la_LIBADD = $(GST_OBJ_LIBS) -noinst_HEADERS = gstcheck.h gst/capslist.h - -AM_CFLAGS = $(GST_OBJ_CFLAGS) $(CHECK_CFLAGS) -LDADD = $(GST_OBJ_LIBS) $(CHECK_LIBS) libgstcheck.la +AM_CFLAGS = $(GST_OBJ_CFLAGS) +LDADD = $(GST_OBJ_LIBS) \ + $(top_builddir)/gst/check/libgstcheck-@GST_MAJORMINOR@.la gst_libs_gdp_SOURCES = \ gst-libs/gdp.c \ @@ -72,7 +70,8 @@ gst_libs_gdp_SOURCES = \ # remove GST_ENABLE_NEW when dataprotocol has been declared API-stable gst_libs_gdp_CFLAGS = $(AM_CFLAGS) -DGST_ENABLE_NEW -gst_libs_controller_LDADD = $(GST_OBJ_LIBS) $(CHECK_LIBS) libgstcheck.la \ +gst_libs_controller_LDADD = $(GST_OBJ_LIBS) \ + $(top_builddir)/gst/check/libgstcheck-@GST_MAJORMINOR@.la \ $(top_builddir)/libs/gst/controller/libgstcontroller-@GST_MAJORMINOR@.la # valgrind testing diff --git a/tests/check/elements/.gitignore b/tests/check/elements/.gitignore index a10e4f5188..3bac562993 100644 --- a/tests/check/elements/.gitignore +++ b/tests/check/elements/.gitignore @@ -1,2 +1,3 @@ .dirstamp -gstfakesrc +fakesrc +identity diff --git a/tests/check/elements/gstfakesrc.c b/tests/check/elements/fakesrc.c similarity index 99% rename from tests/check/elements/gstfakesrc.c rename to tests/check/elements/fakesrc.c index e121684e1f..f5328cc376 100644 --- a/tests/check/elements/gstfakesrc.c +++ b/tests/check/elements/fakesrc.c @@ -22,7 +22,7 @@ #include -#include "../gstcheck.h" +#include GList *buffers = NULL; gboolean have_eos = FALSE; diff --git a/tests/check/elements/identity.c b/tests/check/elements/identity.c new file mode 100644 index 0000000000..3da0ce16b2 --- /dev/null +++ b/tests/check/elements/identity.c @@ -0,0 +1,211 @@ +/* GStreamer + * + * unit test for identity + * + * Copyright (C) <2005> Thomas Vander Stichele + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include + +GList *buffers = NULL; +gboolean have_eos = FALSE; + +/* For ease of programming we use globals to keep refs for our floating + * src and sink pads we create; otherwise we always have to do get_pad, + * get_peer, and then remove references in every test function */ +GstPad *mysrcpad, *mysinkpad; + + +static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); +static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + +GstFlowReturn +chain_func (GstPad * pad, GstBuffer * buffer) +{ + GST_DEBUG ("chain_func: received buffer %p", buffer); + buffers = g_list_append (buffers, buffer); + + return GST_FLOW_OK; +} + +gboolean +event_func (GstPad * pad, GstEvent * event) +{ + if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) { + /* we take the lock here because it's good practice to so, even though + * no buffers will be pushed anymore anyway */ + GST_STREAM_LOCK (pad); + have_eos = TRUE; + GST_STREAM_UNLOCK (pad); + gst_event_unref (event); + return TRUE; + } + + gst_event_unref (event); + return FALSE; +} + +GstElement * +setup_identity () +{ + GstElement *identity; + GstPad *srcpad, *sinkpad; + + GST_DEBUG ("setup_identity"); + + identity = gst_element_factory_make ("identity", "identity"); + fail_if (identity == NULL, "Could not create a identity"); + + /* sending pad */ + mysrcpad = + gst_pad_new_from_template (gst_static_pad_template_get (&srctemplate), + "src"); + fail_if (mysrcpad == NULL, "Could not create a mysrcpad"); + ASSERT_OBJECT_REFCOUNT (mysrcpad, "mysrcpad", 1); + + sinkpad = gst_element_get_pad (identity, "sink"); + fail_if (sinkpad == NULL, "Could not get source pad from identity"); + ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2); + gst_pad_set_caps (mysrcpad, NULL); + fail_unless (gst_pad_link (mysrcpad, sinkpad) == GST_PAD_LINK_OK, + "Could not link source and identity sink pads"); + gst_object_unref (sinkpad); /* because we got it higher up */ + ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 1); + + /* receiving pad */ + mysinkpad = + gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate), + "sink"); + fail_if (mysinkpad == NULL, "Could not create a mysinkpad"); + + srcpad = gst_element_get_pad (identity, "src"); + fail_if (srcpad == NULL, "Could not get source pad from identity"); + gst_pad_set_caps (mysinkpad, NULL); + gst_pad_set_chain_function (mysinkpad, chain_func); + gst_pad_set_event_function (mysinkpad, event_func); + + fail_unless (gst_pad_link (srcpad, mysinkpad) == GST_PAD_LINK_OK, + "Could not link identity source and mysink pads"); + gst_object_unref (srcpad); /* because we got it higher up */ + ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1); + + return identity; +} + +void +cleanup_identity (GstElement * identity) +{ + GstPad *srcpad, *sinkpad; + + GST_DEBUG ("cleanup_identity"); + + fail_unless (gst_element_set_state (identity, GST_STATE_NULL) == + GST_STATE_SUCCESS, "could not set to null"); + ASSERT_OBJECT_REFCOUNT (identity, "identity", 1); + + /* clean up floating src pad */ + sinkpad = gst_element_get_pad (identity, "sink"); + ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2); + + gst_pad_unlink (mysrcpad, sinkpad); + + /* pad refs held by both creator and this function (through _get) */ + ASSERT_OBJECT_REFCOUNT (mysrcpad, "srcpad", 1); + gst_object_unref (mysrcpad); + mysrcpad = NULL; + + ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2); + gst_object_unref (sinkpad); + /* one more ref is held by identity itself */ + + /* clean up floating sink pad */ + srcpad = gst_element_get_pad (identity, "src"); + gst_pad_unlink (srcpad, mysinkpad); + + /* pad refs held by both creator and this function (through _get) */ + ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2); + gst_object_unref (srcpad); + /* one more ref is held by identity itself */ + + ASSERT_OBJECT_REFCOUNT (mysinkpad, "mysinkpad", 1); + gst_object_unref (mysinkpad); + mysinkpad = NULL; + + ASSERT_OBJECT_REFCOUNT (identity, "identity", 1); + gst_object_unref (identity); +} + +GST_START_TEST (test_one_buffer) +{ + GstElement *identity; + GstBuffer *buffer; + + identity = setup_identity (); + fail_unless (gst_element_set_state (identity, + GST_STATE_PLAYING) == GST_STATE_SUCCESS, "could not set to playing"); + + buffer = gst_buffer_new_and_alloc (4); + ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); + memcpy (GST_BUFFER_DATA (buffer), "data", 4); + /* pushing gives away my reference ... */ + gst_pad_push (mysrcpad, buffer); + /* ... but it ends up being collected on the global buffer list */ + ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1); + + /* cleanup */ + cleanup_identity (identity); +} + +GST_END_TEST; + +Suite * +identity_suite (void) +{ + Suite *s = suite_create ("identity"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_one_buffer); + + return s; +} + +int +main (int argc, char **argv) +{ + int nf; + + Suite *s = identity_suite (); + SRunner *sr = srunner_create (s); + + gst_check_init (&argc, &argv); + + srunner_run_all (sr, CK_NORMAL); + nf = srunner_ntests_failed (sr); + srunner_free (sr); + + return nf; +} diff --git a/tests/check/generic/sinks.c b/tests/check/generic/sinks.c index ae295be5d3..84bd9fbecf 100644 --- a/tests/check/generic/sinks.c +++ b/tests/check/generic/sinks.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include /* a sink should go ASYNC to PAUSE. forcing PLAYING is possible */ GST_START_TEST (test_sink) diff --git a/tests/check/gst/gst.c b/tests/check/gst/gst.c index 11ae64a7d9..993c6330c8 100644 --- a/tests/check/gst/gst.c +++ b/tests/check/gst/gst.c @@ -19,7 +19,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_init) { diff --git a/tests/check/gst/gstbin.c b/tests/check/gst/gstbin.c index bf41dc0f8e..61ae0d25cc 100644 --- a/tests/check/gst/gstbin.c +++ b/tests/check/gst/gstbin.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include static void pop_messages (GstBus * bus, int count) diff --git a/tests/check/gst/gstbuffer.c b/tests/check/gst/gstbuffer.c index 801a6096ac..57912147f0 100644 --- a/tests/check/gst/gstbuffer.c +++ b/tests/check/gst/gstbuffer.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_caps) { diff --git a/tests/check/gst/gstbus.c b/tests/check/gst/gstbus.c index f1677ed455..54ea722d3b 100644 --- a/tests/check/gst/gstbus.c +++ b/tests/check/gst/gstbus.c @@ -20,7 +20,7 @@ */ -#include "../gstcheck.h" +#include static GstBus *test_bus = NULL; diff --git a/tests/check/gst/gstcaps.c b/tests/check/gst/gstcaps.c index df5da49613..9141fceb8c 100644 --- a/tests/check/gst/gstcaps.c +++ b/tests/check/gst/gstcaps.c @@ -21,7 +21,7 @@ */ -#include "../gstcheck.h" +#include #include "capslist.h" GST_START_TEST (test_from_string) diff --git a/tests/check/gst/gstelement.c b/tests/check/gst/gstelement.c index 27bd84e010..aeff42d26d 100644 --- a/tests/check/gst/gstelement.c +++ b/tests/check/gst/gstelement.c @@ -19,7 +19,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_add_remove_pad) { diff --git a/tests/check/gst/gstghostpad.c b/tests/check/gst/gstghostpad.c index 274148337f..455dd1f464 100644 --- a/tests/check/gst/gstghostpad.c +++ b/tests/check/gst/gstghostpad.c @@ -19,7 +19,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include static void assert_gstrefcount (gpointer p, gint i) diff --git a/tests/check/gst/gstiterator.c b/tests/check/gst/gstiterator.c index 01378fc23b..ab640040c9 100644 --- a/tests/check/gst/gstiterator.c +++ b/tests/check/gst/gstiterator.c @@ -20,7 +20,7 @@ */ -#include "../gstcheck.h" +#include static GList * diff --git a/tests/check/gst/gstmessage.c b/tests/check/gst/gstmessage.c index 1d6c0c5eb6..0cfad06e5a 100644 --- a/tests/check/gst/gstmessage.c +++ b/tests/check/gst/gstmessage.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include static GQuark domain; diff --git a/tests/check/gst/gstminiobject.c b/tests/check/gst/gstminiobject.c index 7513f34747..c7e61ef841 100644 --- a/tests/check/gst/gstminiobject.c +++ b/tests/check/gst/gstminiobject.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_copy) { diff --git a/tests/check/gst/gstobject.c b/tests/check/gst/gstobject.c index a7dccb36a1..5d8a94f576 100644 --- a/tests/check/gst/gstobject.c +++ b/tests/check/gst/gstobject.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include /* Create a fake subclass diff --git a/tests/check/gst/gstpad.c b/tests/check/gst/gstpad.c index 5283c20805..8a467210d1 100644 --- a/tests/check/gst/gstpad.c +++ b/tests/check/gst/gstpad.c @@ -19,7 +19,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_link) { diff --git a/tests/check/gst/gststructure.c b/tests/check/gst/gststructure.c index cf9eeeb27a..47fc72ad45 100644 --- a/tests/check/gst/gststructure.c +++ b/tests/check/gst/gststructure.c @@ -20,7 +20,7 @@ */ -#include "../gstcheck.h" +#include GST_START_TEST (test_from_string_int) diff --git a/tests/check/gst/gstsystemclock.c b/tests/check/gst/gstsystemclock.c index a20e98f243..f9a6a35136 100644 --- a/tests/check/gst/gstsystemclock.c +++ b/tests/check/gst/gstsystemclock.c @@ -19,7 +19,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include GST_START_TEST (test_signedness) { diff --git a/tests/check/gst/gsttag.c b/tests/check/gst/gsttag.c index 1b3397115d..a91315db90 100644 --- a/tests/check/gst/gsttag.c +++ b/tests/check/gst/gsttag.c @@ -18,7 +18,7 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "../gstcheck.h" +#include #include diff --git a/tests/check/gst/gstvalue.c b/tests/check/gst/gstvalue.c index 4dc3dae289..b492d12db0 100644 --- a/tests/check/gst/gstvalue.c +++ b/tests/check/gst/gstvalue.c @@ -21,7 +21,7 @@ */ -#include "../gstcheck.h" +#include GST_START_TEST (test_deserialize_buffer) diff --git a/tests/check/libs/controller.c b/tests/check/libs/controller.c index dc1e100b80..23d0a0070c 100644 --- a/tests/check/libs/controller.c +++ b/tests/check/libs/controller.c @@ -21,7 +21,7 @@ */ #include "config.h" -#include "../gstcheck.h" +#include #include /* LOCAL TEST ELEMENT */ diff --git a/tests/check/libs/gdp.c b/tests/check/libs/gdp.c index 7a44741b13..69e74e5f4a 100644 --- a/tests/check/libs/gdp.c +++ b/tests/check/libs/gdp.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#include "../gstcheck.h" +#include #include #include "libs/gst/dataprotocol/dp-private.h" /* private header */ diff --git a/tests/check/pipelines/cleanup.c b/tests/check/pipelines/cleanup.c index 7b3a3b4c0f..687244739c 100644 --- a/tests/check/pipelines/cleanup.c +++ b/tests/check/pipelines/cleanup.c @@ -20,7 +20,7 @@ */ -#include "../gstcheck.h" +#include static GstElement * diff --git a/tests/check/pipelines/simple-launch-lines.c b/tests/check/pipelines/simple-launch-lines.c index d29c88efb3..618d3a5577 100644 --- a/tests/check/pipelines/simple-launch-lines.c +++ b/tests/check/pipelines/simple-launch-lines.c @@ -20,7 +20,7 @@ */ -#include "../gstcheck.h" +#include static GstElement *