diff options
Diffstat (limited to 'check')
-rw-r--r-- | check/.gitignore | 1 | ||||
-rw-r--r-- | check/Makefile.am | 34 | ||||
-rw-r--r-- | check/elements/.gitignore | 3 | ||||
-rw-r--r-- | check/elements/level.c | 190 | ||||
-rw-r--r-- | check/elements/matroskamux.c | 427 |
5 files changed, 0 insertions, 655 deletions
diff --git a/check/.gitignore b/check/.gitignore deleted file mode 100644 index 5d45c6c3..00000000 --- a/check/.gitignore +++ /dev/null @@ -1 +0,0 @@ -test-registry.xml diff --git a/check/Makefile.am b/check/Makefile.am deleted file mode 100644 index 256c19a0..00000000 --- a/check/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -include $(top_srcdir)/common/check.mak - -CHECK_REGISTRY = $(top_builddir)/check/test-registry.xml - -REGISTRY_ENVIRONMENT = \ - GST_REGISTRY=$(CHECK_REGISTRY) - -TESTS_ENVIRONMENT = \ - $(REGISTRY_ENVIRONMENT) \ - GST_PLUGIN_SYSTEM_PATH= \ - GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/ext:$(GST_PLUGINS_DIR) - -# ths core dumps of some machines have PIDs appended -CLEANFILES = core.* test-registry.xml - -clean-local: clean-local-check - -TESTS = $(check_PROGRAMS) - -check_PROGRAMS = \ - elements/level \ - elements/matroskamux - - -# these tests don't even pass -noinst_PROGRAMS = - -AM_CFLAGS = $(GST_OBJ_CFLAGS) $(GST_CHECK_CFLAGS) $(CHECK_CFLAGS) -LDADD = $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS) - -# valgrind testing -VALGRIND_TESTS_DISABLE = - -SUPPRESSIONS = $(top_srcdir)/common/gst.supp diff --git a/check/elements/.gitignore b/check/elements/.gitignore deleted file mode 100644 index 312ea60e..00000000 --- a/check/elements/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.dirstamp -level -matroskamux diff --git a/check/elements/level.c b/check/elements/level.c deleted file mode 100644 index b68dac04..00000000 --- a/check/elements/level.c +++ /dev/null @@ -1,190 +0,0 @@ -/* GStreamer - * - * unit test for level - * - * Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org> - * - * 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 <unistd.h> - -#include <gst/check/gstcheck.h> - -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; - -#define LEVEL_CAPS_TEMPLATE_STRING \ - "audio/x-raw-int, " \ - "rate = (int) [ 1, MAX ], " \ - "channels = (int) [ 1, 8 ], " \ - "endianness = (int) BYTE_ORDER, " \ - "width = (int) {8, 16}, " \ - "depth = (int) {8, 16}, " \ - "signed = (boolean) true" - -#define LEVEL_CAPS_STRING \ - "audio/x-raw-int, " \ - "rate = (int) 1000, " \ - "channels = (int) 2, " \ - "endianness = (int) BYTE_ORDER, " \ - "width = (int) 16, " \ - "depth = (int) 16, " \ - "signed = (boolean) true" - - -static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS (LEVEL_CAPS_TEMPLATE_STRING) - ); -static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS (LEVEL_CAPS_TEMPLATE_STRING) - ); - -/* takes over reference for outcaps */ -GstElement * -setup_level () -{ - GstElement *level; - - GST_DEBUG ("setup_level"); - level = gst_check_setup_element ("level"); - mysrcpad = gst_check_setup_src_pad (level, &srctemplate, NULL); - mysinkpad = gst_check_setup_sink_pad (level, &sinktemplate, NULL); - - return level; -} - -void -cleanup_level (GstElement * level) -{ - GST_DEBUG ("cleanup_level"); - - gst_check_teardown_src_pad (level); - gst_check_teardown_sink_pad (level); - gst_check_teardown_element (level); -} - - -GST_START_TEST (test_int16) -{ - GstElement *level; - GstBuffer *inbuffer, *outbuffer; - GstBus *bus; - GstMessage *message; - const GstStructure *structure; - int i, j; - gint16 *data; - const GValue *list, *value; - GstClockTime endtime; - gdouble dB; - - level = setup_level (); - g_object_set (level, "message", TRUE, "interval", GST_SECOND / 10, NULL); - - fail_unless (gst_element_set_state (level, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - /* create a fake 0.1 sec buffer with a half-amplitude block signal */ - inbuffer = gst_buffer_new_and_alloc (400); - data = (gint16 *) GST_BUFFER_DATA (inbuffer); - for (j = 0; j < 200; ++j) { - *data = 16536; - ++data; - } - gst_buffer_set_caps (inbuffer, gst_caps_from_string (LEVEL_CAPS_STRING)); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* create a bus to get the level message on */ - bus = gst_bus_new (); - gst_element_set_bus (level, bus); - - /* pushing gives away my reference ... */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - /* ... but it ends up being collected on the global buffer list */ - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - fail_unless_equals_int (g_list_length (buffers), 1); - fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL); - fail_unless (inbuffer == outbuffer); - - message = gst_bus_poll (bus, GST_MESSAGE_ELEMENT, -1); - - fail_unless (message != NULL); - fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (level)); - fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT); - structure = gst_message_get_structure (message); - fail_if (structure == NULL); - fail_unless_equals_string ((char *) gst_structure_get_name (structure), - "level"); - fail_unless (gst_structure_get_clock_time (structure, "endtime", &endtime)); - - /* block wave of half amplitude has -5.94 dB for rms, peak and decay */ - for (i = 0; i < 2; ++i) { - gchar *fields[3] = { "rms", "peak", "decay" }; - for (j = 0; j < 3; ++j) { - list = gst_structure_get_value (structure, fields[j]); - value = gst_value_list_get_value (list, i); - dB = g_value_get_double (value); - fail_if (dB < -6.0); - fail_if (dB > -5.9); - } - } - - gst_message_unref (message); - // FIXME: need to fix leaks in level object first - //gst_object_unref (level); -} - -GST_END_TEST; - - -Suite * -level_suite (void) -{ - Suite *s = suite_create ("level"); - TCase *tc_chain = tcase_create ("general"); - - suite_add_tcase (s, tc_chain); - tcase_add_test (tc_chain, test_int16); - - return s; -} - -int -main (int argc, char **argv) -{ - int nf; - - Suite *s = level_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/elements/matroskamux.c b/check/elements/matroskamux.c deleted file mode 100644 index 6c1ee77a..00000000 --- a/check/elements/matroskamux.c +++ /dev/null @@ -1,427 +0,0 @@ -/* GStreamer - * - * unit test for matroskamux - * - * Copyright (C) <2005> Michal Benes <michal.benes@xeris.cz> - * - * 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 <unistd.h> - -#include <gst/check/gstcheck.h> - -GList *buffers = NULL; - -/* 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; - -#define AC3_CAPS_STRING "audio/x-ac3, " \ - "channels = (int) 1, " \ - "rate = (int) 8000" -#define VORBIS_CAPS_STRING "audio/x-vorbis, " \ - "channels = (int) 1, " \ - "rate = (int) 8000, " \ - "streamheader=(buffer)<10, 2020, 303030>" - -static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-matroska")); -static GstStaticPadTemplate srcvorbistemplate = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS (VORBIS_CAPS_STRING)); - -static GstStaticPadTemplate srcac3template = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS (AC3_CAPS_STRING)); - - -GstPad * -setup_src_pad (GstElement * element, - GstStaticPadTemplate * template, GstCaps * caps) -{ - GstPad *srcpad, *sinkpad; - - GST_DEBUG_OBJECT (element, "setting up sending pad"); - /* sending pad */ - srcpad = gst_pad_new_from_static_template (template, "src"); - fail_if (srcpad == NULL, "Could not create a srcpad"); - ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1); - - sinkpad = gst_element_get_pad (element, "audio_%d"); - fail_if (sinkpad == NULL, "Could not get sink pad from %s", - GST_ELEMENT_NAME (element)); - ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2); - if (caps) - fail_unless (gst_pad_set_caps (srcpad, caps)); - fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK, - "Could not link source and %s sink pads", GST_ELEMENT_NAME (element)); - gst_object_unref (sinkpad); /* because we got it higher up */ - ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 1); - - return srcpad; -} - -void -teardown_src_pad (GstElement * element) -{ - GstPad *srcpad, *sinkpad; - - /* clean up floating src pad */ - sinkpad = gst_element_get_pad (element, "audio_0"); - ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2); - srcpad = gst_pad_get_peer (sinkpad); - - gst_pad_unlink (srcpad, sinkpad); - - /* pad refs held by both creator and this function (through _get) */ - ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2); - gst_object_unref (sinkpad); - /* one more ref is held by element itself */ - - /* pad refs held by both creator and this function (through _get_peer) */ - ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2); - gst_object_unref (srcpad); - gst_object_unref (srcpad); -} - -GstPad * -setup_sink_pad (GstElement * element, GstStaticPadTemplate * template, - GstCaps * caps) -{ - GstPad *srcpad, *sinkpad; - - GST_DEBUG_OBJECT (element, "setting up receiving pad"); - /* receiving pad */ - sinkpad = gst_pad_new_from_static_template (template, "sink"); - - fail_if (sinkpad == NULL, "Could not create a sinkpad"); - - srcpad = gst_element_get_pad (element, "src"); - fail_if (srcpad == NULL, "Could not get source pad from %s", - GST_ELEMENT_NAME (element)); - if (caps) - fail_unless (gst_pad_set_caps (sinkpad, caps)); - gst_pad_set_chain_function (sinkpad, gst_check_chain_func); - - fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK, - "Could not link %s source and sink pads", GST_ELEMENT_NAME (element)); - gst_object_unref (srcpad); /* because we got it higher up */ - ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 2); - - return sinkpad; -} - -void -teardown_sink_pad (GstElement * element) -{ - GstPad *srcpad, *sinkpad; - - /* clean up floating sink pad */ - srcpad = gst_element_get_pad (element, "src"); - sinkpad = gst_pad_get_peer (srcpad); - gst_pad_unlink (srcpad, sinkpad); - - /* pad refs held by both creator and this function (through _get_pad) */ - ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 3); - gst_object_unref (srcpad); - /* one more ref is held by element itself */ - - /* pad refs held by both creator and this function (through _get_peer) */ - ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 2); - gst_object_unref (sinkpad); - gst_object_unref (sinkpad); -} - - -GstElement * -setup_matroskamux (GstStaticPadTemplate * srctemplate) -{ - GstElement *matroskamux; - - GST_DEBUG ("setup_matroskamux"); - matroskamux = gst_check_setup_element ("matroskamux"); - mysrcpad = setup_src_pad (matroskamux, srctemplate, NULL); - mysinkpad = setup_sink_pad (matroskamux, &sinktemplate, NULL); - - return matroskamux; -} - -void -cleanup_matroskamux (GstElement * matroskamux) -{ - GST_DEBUG ("cleanup_matroskamux"); - gst_element_set_state (matroskamux, GST_STATE_NULL); - - teardown_src_pad (matroskamux); - teardown_sink_pad (matroskamux); - gst_check_teardown_element (matroskamux); -} - -void -check_buffer_data (GstBuffer * buffer, void *data, size_t data_size) -{ - fail_unless (GST_BUFFER_SIZE (buffer) == data_size); - fail_unless (memcmp (data, GST_BUFFER_DATA (buffer), data_size) == 0); -} - -GST_START_TEST (test_ebml_header) -{ - GstElement *matroskamux; - GstBuffer *inbuffer, *outbuffer; - int num_buffers; - int i; - guint8 data0[12] = - { 0x1a, 0x45, 0xdf, 0xa3, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff - }; - guint8 data1[12] = - { 0x42, 0x82, 0x89, 0x6d, 0x61, 0x74, 0x72, 0x6f, 0x73, 0x6b, 0x61, - 0x00 - }; - guint8 data2[4] = { 0x42, 0x87, 0x81, 0x01 }; - guint8 data3[4] = { 0x42, 0x85, 0x81, 0x01 }; - guint8 data4[8] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14 }; - - matroskamux = setup_matroskamux (&srcac3template); - fail_unless (gst_element_set_state (matroskamux, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - inbuffer = gst_buffer_new_and_alloc (1); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - num_buffers = g_list_length (buffers); - fail_unless (num_buffers >= 5); - - for (i = 0; i < num_buffers; ++i) { - outbuffer = GST_BUFFER (buffers->data); - fail_if (outbuffer == NULL); - buffers = g_list_remove (buffers, outbuffer); - - switch (i) { - case 0: - check_buffer_data (outbuffer, data0, sizeof (data0)); - break; - case 1: - check_buffer_data (outbuffer, data1, sizeof (data1)); - break; - case 2: - check_buffer_data (outbuffer, data2, sizeof (data2)); - break; - case 3: - check_buffer_data (outbuffer, data3, sizeof (data3)); - break; - case 4: - check_buffer_data (outbuffer, data4, sizeof (data4)); - break; - default: - break; - } - - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - gst_buffer_unref (outbuffer); - outbuffer = NULL; - } - - cleanup_matroskamux (matroskamux); - g_list_free (buffers); - buffers = NULL; -} - -GST_END_TEST; - - -GST_START_TEST (test_vorbis_header) -{ - GstElement *matroskamux; - GstBuffer *inbuffer, *outbuffer; - GstCaps *caps; - int num_buffers; - int i; - gboolean vorbis_header_found = FALSE; - guint8 data[12] = - { 0x63, 0xa2, 0x89, 0x02, 0x01, 0x02, 0x10, 0x20, 0x20, 0x30, 0x30, - 0x30 - }; - - matroskamux = setup_matroskamux (&srcvorbistemplate); - fail_unless (gst_element_set_state (matroskamux, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - inbuffer = gst_buffer_new_and_alloc (1); - caps = gst_caps_from_string (VORBIS_CAPS_STRING); - gst_buffer_set_caps (inbuffer, caps); - gst_caps_unref (caps); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - num_buffers = g_list_length (buffers); - - for (i = 0; i < num_buffers; ++i) { - outbuffer = GST_BUFFER (buffers->data); - fail_if (outbuffer == NULL); - buffers = g_list_remove (buffers, outbuffer); - - if (!vorbis_header_found && GST_BUFFER_SIZE (outbuffer) == sizeof (data)) { - vorbis_header_found = - memcmp (GST_BUFFER_DATA (outbuffer), data, sizeof (data)); - } - - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - gst_buffer_unref (outbuffer); - outbuffer = NULL; - } - - fail_unless (vorbis_header_found); - - cleanup_matroskamux (matroskamux); - g_list_free (buffers); - buffers = NULL; -} - -GST_END_TEST; - - -GST_START_TEST (test_block_group) -{ - GstElement *matroskamux; - GstBuffer *inbuffer, *outbuffer; - GstCaps *caps; - int num_buffers; - int i; - guint8 data0[9] = { 0xa0, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - guint8 data1[2] = { 0xa1, 0x85 }; - guint8 data2[4] = { 0x81, 0x00, 0x01, 0x00 }; - guint8 data3[1] = { 0x42 }; - guint8 data4[8] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 }; - - matroskamux = setup_matroskamux (&srcac3template); - fail_unless (gst_element_set_state (matroskamux, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - /* Generate the header */ - inbuffer = gst_buffer_new_and_alloc (1); - GST_BUFFER_TIMESTAMP (inbuffer) = 0; - caps = gst_caps_from_string (AC3_CAPS_STRING); - gst_buffer_set_caps (inbuffer, caps); - gst_caps_unref (caps); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - num_buffers = g_list_length (buffers); - - for (i = 0; i < num_buffers; ++i) { - outbuffer = GST_BUFFER (buffers->data); - fail_if (outbuffer == NULL); - buffers = g_list_remove (buffers, outbuffer); - - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - gst_buffer_unref (outbuffer); - outbuffer = NULL; - } - - g_list_free (buffers); - buffers = NULL; - - /* Now push a buffer */ - inbuffer = gst_buffer_new_and_alloc (1); - GST_BUFFER_DATA (inbuffer)[0] = 0x42; - GST_BUFFER_TIMESTAMP (inbuffer) = 1000000; - caps = gst_caps_from_string (AC3_CAPS_STRING); - gst_buffer_set_caps (inbuffer, caps); - gst_caps_unref (caps); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - num_buffers = g_list_length (buffers); - fail_unless (num_buffers >= 5); - - for (i = 0; i < num_buffers; ++i) { - outbuffer = GST_BUFFER (buffers->data); - fail_if (outbuffer == NULL); - buffers = g_list_remove (buffers, outbuffer); - - switch (i) { - case 0: - check_buffer_data (outbuffer, data0, sizeof (data0)); - break; - case 1: - check_buffer_data (outbuffer, data1, sizeof (data1)); - break; - case 2: - check_buffer_data (outbuffer, data2, sizeof (data2)); - break; - case 3: - check_buffer_data (outbuffer, data3, sizeof (data3)); - break; - case 4: - check_buffer_data (outbuffer, data4, sizeof (data4)); - break; - default: - break; - } - - ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); - gst_buffer_unref (outbuffer); - outbuffer = NULL; - } - - g_list_free (buffers); - buffers = NULL; - - cleanup_matroskamux (matroskamux); -} - -GST_END_TEST; - -Suite * -matroskamux_suite (void) -{ - Suite *s = suite_create ("matroskamux"); - TCase *tc_chain = tcase_create ("general"); - - suite_add_tcase (s, tc_chain); - tcase_add_test (tc_chain, test_ebml_header); - tcase_add_test (tc_chain, test_vorbis_header); - tcase_add_test (tc_chain, test_block_group); - - return s; -} - -int -main (int argc, char **argv) -{ - int nf; - - Suite *s = matroskamux_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; -} |