move location of test registry

Original commit message from CVS:
move location of test registry
This commit is contained in:
Thomas Vander Stichele 2005-11-30 17:05:56 +00:00
parent 59823d65b9
commit d8ceb02149
37 changed files with 9 additions and 3380 deletions

View file

@ -12,18 +12,11 @@ else
SUBDIRS_EXAMPLES =
endif
if HAVE_CHECK
SUBDIRS_CHECK = check
else
SUBDIRS_CHECK =
endif
SUBDIRS = \
gst-libs \
gst sys $(SUBDIRS_EXT) \
$(SUBDIRS_EXAMPLES) \
tools \
$(SUBDIRS_CHECK) \
docs \
po \
common \
@ -31,7 +24,6 @@ SUBDIRS = \
pkgconfig
DIST_SUBDIRS = \
check \
docs \
gst-libs \
gst sys ext \
@ -55,7 +47,7 @@ include $(top_srcdir)/common/release.mak
include $(top_srcdir)/common/po.mak
check-valgrind:
cd check && make check-valgrind
cd tests/check && make check-valgrind
check-torture:
cd check && make torture
cd tests/check && make torture

1
check/.gitignore vendored
View file

@ -1 +0,0 @@
test-registry.xml

View file

@ -1,55 +0,0 @@
include $(top_srcdir)/common/check.mak
CHECK_REGISTRY = $(top_builddir)/check/test-registry.xml
REGISTRY_ENVIRONMENT = \
GST_REGISTRY=$(CHECK_REGISTRY)
TESTS_ENVIRONMENT = \
CK_DEFAULT_TIMEOUT=20 \
$(REGISTRY_ENVIRONMENT) \
GST_PLUGIN_SYSTEM_PATH= \
GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/sys:$(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
$(CHECK_REGISTRY):
$(TESTS_ENVIRONMENT)
TESTS = $(check_PROGRAMS)
if USE_VORBIS
check_vorbis = elements/vorbisdec
else
check_vorbis =
endif
check_PROGRAMS = \
elements/audioconvert \
elements/audioresample \
elements/audiotestsrc \
elements/videotestsrc \
elements/volume \
generic/states \
pipelines/simple_launch_lines \
clocks/selection \
$(check_vorbis)
VALGRIND_TO_FIX = \
elements/audioresample \
generic/states \
pipelines/simple_launch_lines
# 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 = $(VALGRIND_TO_FIX)
SUPPRESSIONS = $(top_srcdir)/common/gst.supp

View file

@ -1,2 +0,0 @@
.dirstamp
selection

View file

@ -1,71 +0,0 @@
/* GStreamer
*
* unit test for clock selection
*
* Copyright (C) <2005> Wim Taymans <wim at fluendo dot com>
*
* 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>
GST_START_TEST (test_add)
{
GstElement *pipeline;
GstStateChangeReturn ret;
pipeline = gst_pipeline_new ("pipeline");
fail_unless (pipeline != NULL, "could not create pipeline");
ret = gst_element_set_state (pipeline, GST_STATE_READY);
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "could not set to READY");
/* cleanup */
gst_object_unref (pipeline);
}
GST_END_TEST;
Suite *
volume_suite (void)
{
Suite *s = suite_create ("clocks");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_add);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = volume_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;
}

View file

@ -1,7 +0,0 @@
.dirstamp
audioconvert
audioresample
audiotestsrc
videotestsrc
volume
vorbisdec

View file

@ -1,315 +0,0 @@
/* GStreamer
*
* unit test for audioconvert
*
* 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 CONVERT_CAPS_TEMPLATE_STRING \
"audio/x-raw-float, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, 8 ], " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 32;" \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, 8 ], " \
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) 32, " \
"depth = (int) [ 1, 32 ], " \
"signed = (boolean) { true, false }; " \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, 8 ], " \
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) 24, " \
"depth = (int) [ 1, 24 ], " \
"signed = (boolean) { true, false }; " \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, 8 ], " \
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) 16, " \
"depth = (int) [ 1, 16 ], " \
"signed = (boolean) { true, false }; " \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, 8 ], " \
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) 8, " \
"depth = (int) [ 1, 8 ], " \
"signed = (boolean) { true, false } "
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (CONVERT_CAPS_TEMPLATE_STRING)
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (CONVERT_CAPS_TEMPLATE_STRING)
);
/* takes over reference for outcaps */
GstElement *
setup_audioconvert (GstCaps * outcaps)
{
GstElement *audioconvert;
GST_DEBUG ("setup_audioconvert with caps %" GST_PTR_FORMAT, outcaps);
audioconvert = gst_check_setup_element ("audioconvert");
mysrcpad = gst_check_setup_src_pad (audioconvert, &srctemplate, NULL);
mysinkpad = gst_check_setup_sink_pad (audioconvert, &sinktemplate, NULL);
/* this installs a getcaps func that will always return the caps we set
* later */
gst_pad_use_fixed_caps (mysinkpad);
gst_pad_set_caps (mysinkpad, outcaps);
gst_caps_unref (outcaps);
outcaps = gst_pad_get_negotiated_caps (mysinkpad);
fail_unless (gst_caps_is_fixed (outcaps));
gst_caps_unref (outcaps);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
return audioconvert;
}
void
cleanup_audioconvert (GstElement * audioconvert)
{
GST_DEBUG ("cleanup_audioconvert");
gst_pad_set_active (mysrcpad, FALSE);
gst_pad_set_active (mysinkpad, FALSE);
gst_check_teardown_src_pad (audioconvert);
gst_check_teardown_sink_pad (audioconvert);
gst_check_teardown_element (audioconvert);
}
/* returns a newly allocated caps */
static GstCaps *
get_int_caps (guint channels, gchar * endianness, guint width,
guint depth, gboolean signedness)
{
GstCaps *caps;
gchar *string;
string = g_strdup_printf ("audio/x-raw-int, "
"rate = (int) 44100, "
"channels = (int) %d, "
"endianness = (int) %s, "
"width = (int) %d, "
"depth = (int) %d, "
"signed = (boolean) %s ",
channels, endianness, width, depth, signedness ? "true" : "false");
GST_DEBUG ("creating caps from %s", string);
caps = gst_caps_from_string (string);
g_free (string);
fail_unless (caps != NULL);
GST_DEBUG ("returning caps %p", caps);
return caps;
}
/* eats the refs to the caps */
static void
verify_convert (void *in, int inlength,
GstCaps * incaps, void *out, int outlength, GstCaps * outcaps)
{
GstBuffer *inbuffer, *outbuffer;
GstElement *audioconvert;
GST_DEBUG ("incaps: %" GST_PTR_FORMAT, incaps);
GST_DEBUG ("outcaps: %" GST_PTR_FORMAT, outcaps);
ASSERT_CAPS_REFCOUNT (incaps, "incaps", 1);
ASSERT_CAPS_REFCOUNT (outcaps, "outcaps", 1);
audioconvert = setup_audioconvert (outcaps);
ASSERT_CAPS_REFCOUNT (outcaps, "outcaps", 1);
fail_unless (gst_element_set_state (audioconvert,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
GST_DEBUG ("Creating buffer of %d bytes", inlength);
inbuffer = gst_buffer_new_and_alloc (inlength);
memcpy (GST_BUFFER_DATA (inbuffer), in, inlength);
gst_buffer_set_caps (inbuffer, incaps);
ASSERT_CAPS_REFCOUNT (incaps, "incaps", 2);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* pushing gives away my reference ... */
GST_DEBUG ("push it");
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
GST_DEBUG ("pushed it");
/* ... and puts a new buffer on the global list */
fail_unless (g_list_length (buffers) == 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), outlength);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, outlength) == 0);
buffers = g_list_remove (buffers, outbuffer);
gst_buffer_unref (outbuffer);
fail_unless (gst_element_set_state (audioconvert,
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
/* cleanup */
GST_DEBUG ("cleanup audioconvert");
cleanup_audioconvert (audioconvert);
GST_DEBUG ("cleanup, unref incaps");
ASSERT_CAPS_REFCOUNT (incaps, "incaps", 1);
gst_caps_unref (incaps);
}
#define RUN_CONVERSION(inarray, in_get_caps, outarray, out_get_caps) \
verify_convert (inarray, sizeof (inarray), \
in_get_caps, outarray, sizeof (outarray), out_get_caps)
GST_START_TEST (test_int16)
{
/* stereo to mono */
{
gint16 in[] = { 16384, -256, 1024, 1024 };
gint16 out[] = { 8064, 1024 };
RUN_CONVERSION (in, get_int_caps (2, "BYTE_ORDER", 16, 16, TRUE),
out, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE));
}
/* mono to stereo */
{
gint16 in[] = { 512, 1024 };
gint16 out[] = { 512, 512, 1024, 1024 };
RUN_CONVERSION (in, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE),
out, get_int_caps (2, "BYTE_ORDER", 16, 16, TRUE));
}
/* signed -> unsigned */
{
gint16 in[] = { 0, -32767, 32767, -32768 };
guint16 out[] = { 32768, 1, 65535, 0 };
RUN_CONVERSION (in, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE),
out, get_int_caps (1, "BYTE_ORDER", 16, 16, FALSE));
RUN_CONVERSION (out, get_int_caps (1, "BYTE_ORDER", 16, 16, FALSE),
in, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE));
}
}
GST_END_TEST;
GST_START_TEST (test_int_conversion)
{
/* 8 <-> 16 signed */
/* NOTE: if audioconvert was doing dithering we'd have a problem */
{
gint8 in[] = { 0, 1, 2, 127, -127 };
gint16 out[] = { 0, 256, 512, 32512, -32512 };
RUN_CONVERSION (in, get_int_caps (1, "BYTE_ORDER", 8, 8, TRUE),
out, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE)
);
RUN_CONVERSION (out, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE),
in, get_int_caps (1, "BYTE_ORDER", 8, 8, TRUE)
);
}
/* 16 -> 8 signed */
{
gint16 in[] = { 0, 255, 256, 257 };
gint8 out[] = { 0, 0, 1, 1 };
RUN_CONVERSION (in, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE),
out, get_int_caps (1, "BYTE_ORDER", 8, 8, TRUE)
);
}
/* 8 unsigned <-> 16 signed */
/* NOTE: if audioconvert was doing dithering we'd have a problem */
{
guint8 in[] = { 128, 129, 130, 255, 1 };
gint16 out[] = { 0, 256, 512, 32512, -32512 };
GstCaps *incaps, *outcaps;
/* exploded for easier valgrinding */
incaps = get_int_caps (1, "BYTE_ORDER", 8, 8, FALSE);
outcaps = get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE);
GST_DEBUG ("incaps: %" GST_PTR_FORMAT, incaps);
GST_DEBUG ("outcaps: %" GST_PTR_FORMAT, outcaps);
RUN_CONVERSION (in, incaps, out, outcaps);
RUN_CONVERSION (out, get_int_caps (1, "BYTE_ORDER", 16, 16, TRUE),
in, get_int_caps (1, "BYTE_ORDER", 8, 8, FALSE)
);
}
/* 8 <-> 24 signed */
/* NOTE: if audioconvert was doing dithering we'd have a problem */
{
gint8 in[] = { 0, 1, 127 };
guint8 out[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x7f };
RUN_CONVERSION (in, get_int_caps (1, "BYTE_ORDER", 8, 8, TRUE),
out, get_int_caps (1, "BYTE_ORDER", 24, 24, TRUE)
);
RUN_CONVERSION (out, get_int_caps (1, "BYTE_ORDER", 24, 24, TRUE),
in, get_int_caps (1, "BYTE_ORDER", 8, 8, TRUE)
);
}
}
GST_END_TEST;
Suite *
audioconvert_suite (void)
{
Suite *s = suite_create ("audioconvert");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_int16);
//tcase_add_test (tc_chain, test_int_conversion);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = audioconvert_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;
}

View file

@ -1,247 +0,0 @@
/* GStreamer
*
* unit test for audioresample
*
* 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 RESAMPLE_CAPS_TEMPLATE_STRING \
"audio/x-raw-int, " \
"channels = (int) [ 1, MAX ], " \
"rate = (int) [ 1, MAX ], " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 16, " \
"depth = (int) 16, " \
"signed = (bool) TRUE"
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (RESAMPLE_CAPS_TEMPLATE_STRING)
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (RESAMPLE_CAPS_TEMPLATE_STRING)
);
GstElement *
setup_audioresample (int channels, int inrate, int outrate)
{
GstElement *audioresample;
GstCaps *caps;
GstStructure *structure;
GstPad *pad;
GST_DEBUG ("setup_audioresample");
audioresample = gst_check_setup_element ("audioresample");
caps = gst_caps_from_string (RESAMPLE_CAPS_TEMPLATE_STRING);
structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, inrate, NULL);
fail_unless (gst_caps_is_fixed (caps));
mysrcpad = gst_check_setup_src_pad (audioresample, &srctemplate, caps);
pad = gst_pad_get_peer (mysrcpad);
gst_pad_set_caps (pad, caps);
gst_object_unref (GST_OBJECT (pad));
gst_caps_unref (caps);
gst_pad_set_active (mysrcpad, TRUE);
caps = gst_caps_from_string (RESAMPLE_CAPS_TEMPLATE_STRING);
structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, outrate, NULL);
fail_unless (gst_caps_is_fixed (caps));
mysinkpad = gst_check_setup_sink_pad (audioresample, &sinktemplate, caps);
/* this installs a getcaps func that will always return the caps we set
* later */
gst_pad_use_fixed_caps (mysinkpad);
pad = gst_pad_get_peer (mysinkpad);
gst_pad_set_caps (pad, caps);
gst_object_unref (GST_OBJECT (pad));
gst_caps_unref (caps);
gst_pad_set_active (mysinkpad, TRUE);
return audioresample;
}
void
cleanup_audioresample (GstElement * audioresample)
{
GST_DEBUG ("cleanup_audioresample");
gst_check_teardown_src_pad (audioresample);
gst_check_teardown_sink_pad (audioresample);
gst_check_teardown_element (audioresample);
}
static void
fail_unless_perfect_stream ()
{
guint64 timestamp = 0L, duration = 0L;
guint64 offset = 0L, offset_end = 0L;
GList *l;
GstBuffer *buffer;
for (l = buffers; l; l = l->next) {
buffer = GST_BUFFER (l->data);
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
GST_DEBUG ("buffer timestamp %" G_GUINT64_FORMAT ", duration %"
G_GUINT64_FORMAT, GST_BUFFER_TIMESTAMP (buffer),
GST_BUFFER_DURATION (buffer));
fail_unless_equals_uint64 (timestamp, GST_BUFFER_TIMESTAMP (buffer));
fail_unless_equals_uint64 (offset, GST_BUFFER_OFFSET (buffer));
duration = GST_BUFFER_DURATION (buffer);
offset_end = GST_BUFFER_OFFSET_END (buffer);
timestamp += duration;
offset = offset_end;
gst_buffer_unref (buffer);
}
g_list_free (buffers);
buffers = NULL;
}
static void
test_perfect_stream_instance (int inrate, int outrate, int samples,
int numbuffers)
{
GstElement *audioresample;
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
int i, j;
gint16 *p;
audioresample = setup_audioresample (2, inrate, outrate);
caps = gst_pad_get_negotiated_caps (mysrcpad);
fail_unless (gst_caps_is_fixed (caps));
fail_unless (gst_element_set_state (audioresample,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
for (j = 1; j <= numbuffers; ++j) {
inbuffer = gst_buffer_new_and_alloc (samples * 4);
GST_BUFFER_DURATION (inbuffer) = samples * GST_SECOND / inrate;
GST_BUFFER_TIMESTAMP (inbuffer) = GST_BUFFER_DURATION (inbuffer) * (j - 1);
GST_BUFFER_OFFSET (inbuffer) = 0;
GST_BUFFER_OFFSET_END (inbuffer) = samples;
gst_buffer_set_caps (inbuffer, caps);
p = (gint16 *) GST_BUFFER_DATA (inbuffer);
/* create a 16 bit signed ramp */
for (i = 0; i < samples; ++i) {
*p = -32767 + i * (65535 / samples);
++p;
*p = -32767 + i * (65535 / samples);
++p;
}
/* 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 */
fail_unless_equals_int (g_list_length (buffers), j);
}
/* FIXME: we should make audioresample handle eos by flushing out the last
* samples, which will give us one more, small, buffer */
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
fail_unless_perfect_stream ();
/* cleanup */
gst_caps_unref (caps);
cleanup_audioresample (audioresample);
}
/* make sure that outgoing buffers are contiguous in timestamp/duration and
* offset/offsetend
*/
GST_START_TEST (test_perfect_stream)
{
guint inrate, outrate, bytes;
/* integral scalings */
test_perfect_stream_instance (48000, 24000, 500, 20);
test_perfect_stream_instance (48000, 12000, 500, 20);
test_perfect_stream_instance (12000, 24000, 500, 20);
test_perfect_stream_instance (12000, 48000, 500, 20);
/* non-integral scalings */
test_perfect_stream_instance (44100, 8000, 500, 20);
test_perfect_stream_instance (8000, 44100, 500, 20);
/* wacky scalings */
test_perfect_stream_instance (12345, 54321, 500, 20);
test_perfect_stream_instance (101, 99, 500, 20);
}
GST_END_TEST;
Suite *
audioresample_suite (void)
{
Suite *s = suite_create ("audioresample");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_perfect_stream);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = audioresample_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;
}

View file

@ -1,142 +0,0 @@
/* GStreamer
*
* unit test for audiotestsrc
*
* 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 *mysinkpad;
#define CAPS_TEMPLATE_STRING \
"audio/x-raw-int, " \
"channels = (int) 1, " \
"rate = (int) [ 1, MAX ], " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 16, " \
"depth = (int) 16, " \
"signed = (bool) TRUE"
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (CAPS_TEMPLATE_STRING)
);
GstElement *
setup_audiotestsrc ()
{
GstElement *audiotestsrc;
GST_DEBUG ("setup_audiotestsrc");
audiotestsrc = gst_check_setup_element ("audiotestsrc");
mysinkpad = gst_check_setup_sink_pad (audiotestsrc, &sinktemplate, NULL);
gst_pad_set_active (mysinkpad, TRUE);
return audiotestsrc;
}
void
cleanup_audiotestsrc (GstElement * audiotestsrc)
{
GST_DEBUG ("cleanup_audiotestsrc");
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
g_list_free (buffers);
buffers = NULL;
gst_check_teardown_sink_pad (audiotestsrc);
gst_check_teardown_element (audiotestsrc);
}
GST_START_TEST (test_all_waves)
{
GstElement *audiotestsrc;
GObjectClass *oclass;
GParamSpec *property;
GEnumValue *values;
guint j = 0;
audiotestsrc = setup_audiotestsrc ();
oclass = G_OBJECT_GET_CLASS (audiotestsrc);
property = g_object_class_find_property (oclass, "wave");
fail_unless (G_IS_PARAM_SPEC_ENUM (property));
values = G_ENUM_CLASS (g_type_class_ref (property->value_type))->values;
while (values[j].value_name) {
GST_DEBUG_OBJECT (audiotestsrc, "testing wave %s", values[j].value_name);
fail_unless (gst_element_set_state (audiotestsrc,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
while (g_list_length (buffers) < 10);
gst_element_set_state (audiotestsrc, GST_STATE_READY);
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
g_list_free (buffers);
buffers = NULL;
++j;
}
/* cleanup */
cleanup_audiotestsrc (audiotestsrc);
}
GST_END_TEST;
Suite *
audiotestsrc_suite (void)
{
Suite *s = suite_create ("audiotestsrc");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_all_waves);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = audiotestsrc_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;
}

View file

@ -1,143 +0,0 @@
/* GStreamer
*
* unit test for videotestsrc
*
* 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 *mysinkpad;
#define CAPS_TEMPLATE_STRING \
"video/x-raw-yuv, " \
"format = (fourcc) Y422, " \
"width = (int) [ 1, MAX ], " \
"height = (int) [ 1, MAX ], " \
"framerate = (fraction) [ 0/1, MAX ]"
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (CAPS_TEMPLATE_STRING)
);
GstElement *
setup_videotestsrc ()
{
GstElement *videotestsrc;
GST_DEBUG ("setup_videotestsrc");
videotestsrc = gst_check_setup_element ("videotestsrc");
mysinkpad = gst_check_setup_sink_pad (videotestsrc, &sinktemplate, NULL);
gst_pad_set_active (mysinkpad, TRUE);
return videotestsrc;
}
void
cleanup_videotestsrc (GstElement * videotestsrc)
{
GST_DEBUG ("cleanup_videotestsrc");
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
g_list_free (buffers);
buffers = NULL;
gst_check_teardown_sink_pad (videotestsrc);
gst_check_teardown_element (videotestsrc);
}
GST_START_TEST (test_all_patterns)
{
GstElement *videotestsrc;
GObjectClass *oclass;
GParamSpec *property;
GEnumValue *values;
guint j = 0;
videotestsrc = setup_videotestsrc ();
oclass = G_OBJECT_GET_CLASS (videotestsrc);
property = g_object_class_find_property (oclass, "pattern");
fail_unless (G_IS_PARAM_SPEC_ENUM (property));
values = G_ENUM_CLASS (g_type_class_ref (property->value_type))->values;
while (values[j].value_name) {
GST_DEBUG_OBJECT (videotestsrc, "testing pattern %s", values[j].value_name);
fail_unless (gst_element_set_state (videotestsrc,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
while (g_list_length (buffers) < 10);
gst_element_set_state (videotestsrc, GST_STATE_READY);
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
g_list_free (buffers);
buffers = NULL;
++j;
}
/* cleanup */
cleanup_videotestsrc (videotestsrc);
}
GST_END_TEST;
/* FIXME:
* add tests for every colorspace */
Suite *
videotestsrc_suite (void)
{
Suite *s = suite_create ("videotestsrc");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_all_patterns);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = videotestsrc_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;
}

View file

@ -1,302 +0,0 @@
/* GStreamer
*
* unit test for volume
*
* 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 VOLUME_CAPS_TEMPLATE_STRING \
"audio/x-raw-int, " \
"channels = (int) [ 1, MAX ], " \
"rate = (int) [ 1, MAX ], " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 16, " \
"depth = (int) 16, " \
"signed = (bool) TRUE"
#define VOLUME_CAPS_STRING \
"audio/x-raw-int, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 16, " \
"depth = (int) 16, " \
"signed = (bool) TRUE"
#define VOLUME_WRONG_CAPS_STRING \
"audio/x-raw-int, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 16, " \
"depth = (int) 16, " \
"signed = (bool) FALSE"
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (VOLUME_CAPS_TEMPLATE_STRING)
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (VOLUME_CAPS_TEMPLATE_STRING)
);
GstElement *
setup_volume ()
{
GstElement *volume;
GST_DEBUG ("setup_volume");
volume = gst_check_setup_element ("volume");
mysrcpad = gst_check_setup_src_pad (volume, &srctemplate, NULL);
mysinkpad = gst_check_setup_sink_pad (volume, &sinktemplate, NULL);
gst_pad_set_active (mysrcpad, TRUE);
gst_pad_set_active (mysinkpad, TRUE);
return volume;
}
void
cleanup_volume (GstElement * volume)
{
GST_DEBUG ("cleanup_volume");
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
g_list_free (buffers);
buffers = NULL;
gst_check_teardown_src_pad (volume);
gst_check_teardown_sink_pad (volume);
gst_check_teardown_element (volume);
}
GST_START_TEST (test_unity)
{
GstElement *volume;
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
volume = setup_volume ();
fail_unless (gst_element_set_state (volume,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
caps = gst_caps_from_string (VOLUME_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* 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);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
/* cleanup */
cleanup_volume (volume);
}
GST_END_TEST;
GST_START_TEST (test_half)
{
GstElement *volume;
GstBuffer *inbuffer;
GstBuffer *outbuffer;
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 out[2] = { 8192, -128 };
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
fail_unless (gst_element_set_state (volume,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
caps = gst_caps_from_string (VOLUME_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be
* inplace
gst_buffer_ref (inbuffer);
*/
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
/* ... but it ends up being modified inplace and
* 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);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 4) == 0);
/* cleanup */
cleanup_volume (volume);
}
GST_END_TEST;
GST_START_TEST (test_double)
{
GstElement *volume;
GstBuffer *inbuffer;
GstBuffer *outbuffer;
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 out[2] = { 32767, -512 }; /* notice the clamped sample */
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
fail_unless (gst_element_set_state (volume,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 4) == 0);
caps = gst_caps_from_string (VOLUME_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* FIXME: reffing the inbuffer should make the transformation not be
* inplace
gst_buffer_ref (inbuffer);
*/
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
/* ... but it ends up being modified inplace and
* 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);
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, 4) == 0);
/* cleanup */
cleanup_volume (volume);
}
GST_END_TEST;
GST_START_TEST (test_wrong_caps)
{
GstElement *volume;
GstBuffer *inbuffer, *outbuffer;
gint16 in[2] = { 16384, -256 };
GstBus *bus;
GstMessage *message;
GstCaps *caps;
volume = setup_volume ();
bus = gst_bus_new ();
fail_unless (gst_element_set_state (volume,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (inbuffer), in, 4);
caps = gst_caps_from_string (VOLUME_WRONG_CAPS_STRING);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
gst_buffer_ref (inbuffer);
/* set a bus here so we avoid getting state change messages */
gst_element_set_bus (volume, bus);
/* pushing gives an error because it can't negotiate with wrong caps */
fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer),
GST_FLOW_NOT_NEGOTIATED);
/* ... and the buffer would have been lost if we didn't ref it ourselves */
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
gst_buffer_unref (inbuffer);
fail_unless_equals_int (g_list_length (buffers), 0);
/* volume_set_caps should not have been called since basetransform caught
* the negotiation problem */
fail_if ((message = gst_bus_pop (bus)) != NULL);
/* cleanup */
gst_element_set_bus (volume, NULL);
gst_object_unref (GST_OBJECT (bus));
cleanup_volume (volume);
}
GST_END_TEST;
Suite *
volume_suite (void)
{
Suite *s = suite_create ("volume");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_unity);
tcase_add_test (tc_chain, test_half);
tcase_add_test (tc_chain, test_double);
tcase_add_test (tc_chain, test_wrong_caps);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = volume_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;
}

View file

@ -1,260 +0,0 @@
/* GStreamer
*
* unit test for vorbisdec
*
* 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;
/* 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;
/* a valid first header packet */
guchar identification_header[30] = {
1, /* packet_type */
'v', 'o', 'r', 'b', 'i', 's',
0, 0, 0, 0, /* vorbis_version */
2, /* audio_channels */
0x44, 0xac, 0, 0, /* sample_rate */
0xff, 0xff, 0xff, 0xff, /* bitrate_maximum */
0x00, 0xee, 0x02, 0x00, /* bitrate_nominal */
0xff, 0xff, 0xff, 0xff, /* bitrate_minimum */
0xb8, /* blocksize_0, blocksize_1 */
0x01, /* framing_flag */
};
guchar comment_header[] = {
3, /* packet_type */
'v', 'o', 'r', 'b', 'i', 's',
2, 0, 0, 0, /* vendor_length */
'm', 'e',
1, 0, 0, 0, /* user_comment_list_length */
9, 0, 0, 0, /* length comment[0] */
'A', 'R', 'T', 'I', 'S', 'T', '=', 'm', 'e',
0x01, /* framing bit */
};
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);
GstElement *
setup_vorbisdec ()
{
GstElement *vorbisdec;
GST_DEBUG ("setup_vorbisdec");
vorbisdec = gst_check_setup_element ("vorbisdec");
mysrcpad = gst_check_setup_src_pad (vorbisdec, &srctemplate, NULL);
mysinkpad = gst_check_setup_sink_pad (vorbisdec, &sinktemplate, NULL);
return vorbisdec;
}
void
cleanup_vorbisdec (GstElement * vorbisdec)
{
GST_DEBUG ("cleanup_vorbisdec");
gst_element_set_state (vorbisdec, GST_STATE_NULL);
gst_check_teardown_src_pad (vorbisdec);
gst_check_teardown_sink_pad (vorbisdec);
gst_check_teardown_element (vorbisdec);
}
GST_START_TEST (test_wrong_channels_identification_header)
{
GstElement *vorbisdec;
GstBuffer *inbuffer, *outbuffer;
GstBus *bus;
GstMessage *message;
vorbisdec = setup_vorbisdec ();
fail_unless (gst_element_set_state (vorbisdec,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
bus = gst_bus_new ();
inbuffer = gst_buffer_new_and_alloc (30);
memcpy (GST_BUFFER_DATA (inbuffer), identification_header, 30);
/* set the channel count to 7, which is not supported */
GST_BUFFER_DATA (inbuffer)[11] = 7;
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
gst_buffer_ref (inbuffer);
gst_element_set_bus (vorbisdec, bus);
/* pushing gives away my reference ... */
fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_ERROR);
/* ... and nothing ends up on the global buffer list */
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
gst_buffer_unref (inbuffer);
fail_unless_equals_int (g_list_length (buffers), 0);
fail_if ((message = gst_bus_pop (bus)) == NULL);
fail_unless_message_error (message, STREAM, NOT_IMPLEMENTED);
gst_message_unref (message);
gst_element_set_bus (vorbisdec, NULL);
/* cleanup */
gst_object_unref (GST_OBJECT (bus));
cleanup_vorbisdec (vorbisdec);
}
GST_END_TEST;
GST_START_TEST (test_empty_identification_header)
{
GstElement *vorbisdec;
GstBuffer *inbuffer, *outbuffer;
GstBus *bus;
GstMessage *message;
vorbisdec = setup_vorbisdec ();
bus = gst_bus_new ();
fail_unless (gst_element_set_state (vorbisdec,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
inbuffer = gst_buffer_new_and_alloc (0);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
/* set a bus here so we avoid getting state change messages */
gst_element_set_bus (vorbisdec, bus);
fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_ERROR);
/* ... but it ends up being collected on the global buffer list */
fail_unless_equals_int (g_list_length (buffers), 0);
fail_if ((message = gst_bus_pop (bus)) == NULL);
fail_unless_message_error (message, STREAM, DECODE);
gst_message_unref (message);
gst_element_set_bus (vorbisdec, NULL);
/* cleanup */
gst_object_unref (GST_OBJECT (bus));
cleanup_vorbisdec (vorbisdec);
}
GST_END_TEST;
/* FIXME: also tests comment header */
GST_START_TEST (test_identification_header)
{
GstElement *vorbisdec;
GstBuffer *inbuffer, *outbuffer;
GstBus *bus;
GstMessage *message;
GstTagList *tag_list;
gchar *artist;
vorbisdec = setup_vorbisdec ();
fail_unless (gst_element_set_state (vorbisdec,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
bus = gst_bus_new ();
inbuffer = gst_buffer_new_and_alloc (30);
memcpy (GST_BUFFER_DATA (inbuffer), identification_header, 30);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
gst_buffer_ref (inbuffer);
gst_element_set_bus (vorbisdec, bus);
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
/* ... and nothing ends up on the global buffer list */
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
gst_buffer_unref (inbuffer);
fail_unless (g_list_length (buffers) == 0);
fail_if ((message = gst_bus_pop (bus)) != NULL);
inbuffer = gst_buffer_new_and_alloc (sizeof (comment_header));
memcpy (GST_BUFFER_DATA (inbuffer), comment_header, sizeof (comment_header));
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
gst_buffer_ref (inbuffer);
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
/* ... and nothing ends up on the global buffer list */
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
gst_buffer_unref (inbuffer);
fail_unless (g_list_length (buffers) == 0);
/* there's a tag message waiting */
fail_if ((message = gst_bus_pop (bus)) == NULL);
gst_message_parse_tag (message, &tag_list);
fail_unless_equals_int (gst_tag_list_get_tag_size (tag_list, GST_TAG_ARTIST),
1);
fail_unless (gst_tag_list_get_string (tag_list, GST_TAG_ARTIST, &artist));
fail_unless_equals_string (artist, "me");
g_free (artist);
fail_unless_equals_int (gst_tag_list_get_tag_size (tag_list, "album"), 0);
gst_tag_list_free (tag_list);
gst_message_unref (message);
/* cleanup */
gst_bus_set_flushing (bus, TRUE);
gst_element_set_bus (vorbisdec, NULL);
gst_object_unref (GST_OBJECT (bus));
cleanup_vorbisdec (vorbisdec);
}
GST_END_TEST;
Suite *
vorbisdec_suite (void)
{
Suite *s = suite_create ("vorbisdec");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_empty_identification_header);
tcase_add_test (tc_chain, test_wrong_channels_identification_header);
tcase_add_test (tc_chain, test_identification_header);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = vorbisdec_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;
}

View file

@ -1,2 +0,0 @@
.dirstamp
states

View file

@ -1,109 +0,0 @@
/* GStreamer
*
* unit test for state changes on all elements
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <unistd.h>
#include <gst/check/gstcheck.h>
GST_START_TEST (test_state_changes)
{
GstElement *element;
GList *features, *f;
GList *plugins, *p;
GST_DEBUG ("testing elements from source %s", PACKAGE);
plugins = gst_registry_get_plugin_list (gst_registry_get_default ());
for (p = plugins; p; p = p->next) {
GstPlugin *plugin = p->data;
if (strcmp (gst_plugin_get_source (plugin), PACKAGE) != 0)
continue;
features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
gst_plugin_get_name (plugin));
for (f = features; f; f = f->next) {
GstPluginFeature *feature = f->data;
const gchar *name = gst_plugin_feature_get_name (feature);
if (!GST_IS_ELEMENT_FACTORY (feature))
continue;
GST_DEBUG ("testing element %s", name);
element = gst_element_factory_make (name, name);
if (GST_IS_PIPELINE (element)) {
GST_DEBUG ("element %s is a pipeline", name);
}
gst_element_set_state (element, GST_STATE_READY);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_PLAYING);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_READY);
gst_element_set_state (element, GST_STATE_NULL);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_READY);
gst_element_set_state (element, GST_STATE_PLAYING);
gst_element_set_state (element, GST_STATE_PAUSED);
gst_element_set_state (element, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (element));
}
}
}
GST_END_TEST;
Suite *
states_suite (void)
{
Suite *s = suite_create ("states");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_state_changes);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = states_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;
}

View file

@ -1,2 +0,0 @@
.dirstamp
simple_launch_lines

View file

@ -1,181 +0,0 @@
/* GStreamer
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
*
* simple_launch_lines.c: Unit test for simple pipelines
*
* 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 <gst/check/gstcheck.h>
static GstElement *
setup_pipeline (const gchar * pipe_descr)
{
GstElement *pipeline;
pipeline = gst_parse_launch (pipe_descr, NULL);
g_return_val_if_fail (GST_IS_PIPELINE (pipeline), NULL);
return pipeline;
}
/*
* run_pipeline:
* @pipe: the pipeline to run
* @desc: the description for use in messages
* @events: is a mask of expected events
* @tevent: is the expected terminal event.
*
* the poll call will time out after half a second.
*/
static void
run_pipeline (GstElement * pipe, const gchar * descr,
GstMessageType events, GstMessageType tevent)
{
GstBus *bus;
GstMessage *message;
GstMessageType revent;
GstStateChangeReturn ret;
g_assert (pipe);
bus = gst_element_get_bus (pipe);
g_assert (bus);
ret = gst_element_set_state (pipe, GST_STATE_PLAYING);
ret = gst_element_get_state (pipe, NULL, NULL, GST_CLOCK_TIME_NONE);
if (ret != GST_STATE_CHANGE_SUCCESS) {
g_critical ("Couldn't set pipeline to PLAYING");
goto done;
}
while (1) {
message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 2);
/* always have to pop the message before getting back into poll */
if (message) {
revent = GST_MESSAGE_TYPE (message);
gst_message_unref (message);
} else {
revent = GST_MESSAGE_UNKNOWN;
}
if (revent == tevent) {
break;
} else if (revent == GST_MESSAGE_UNKNOWN) {
g_critical ("Unexpected timeout in gst_bus_poll, looking for %d: %s",
tevent, descr);
break;
} else if (revent & events) {
continue;
}
g_critical ("Unexpected message received of type %d, looking for %d: %s",
revent, tevent, descr);
}
done:
gst_element_set_state (pipe, GST_STATE_NULL);
gst_object_unref (pipe);
}
GST_START_TEST (test_element_negotiation)
{
gchar *s;
/* see http://bugzilla.gnome.org/show_bug.cgi?id=315126 */
s = "fakesrc ! audio/x-raw-int,width=16,depth=16,rate=22050,channels=1 ! audioconvert ! audio/x-raw-int,width=16,depth=16,rate=22050,channels=1 ! fakesink";
run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN);
#ifdef HAVE_LIBVISUAL
s = "audiotestsrc ! tee name=t ! alsasink t. ! audioconvert ! libvisual_lv_scope ! ffmpegcolorspace ! xvimagesink";
run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN);
#endif
}
GST_END_TEST
GST_START_TEST (test_basetransform_based)
{
/* Each of these tests is to check whether various basetransform based elements can
* select output caps when not allowed to do passthrough and going to a generic sink
* such as fakesink or filesink */
const gchar *s;
/* Check that videoscale can pick a height given only a width */
s = "videotestsrc ! video/x-raw-yuv,format=(fourcc)I420,width=320,height=240 ! " "videoscale ! video/x-raw-yuv,width=640 ! fakesink";
run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN);
/* Test that ffmpegcolorspace can pick an output format that isn't
* passthrough without completely specified output caps */
s = "videotestsrc ! "
"video/x-raw-yuv,format=(fourcc)I420,width=320,height=240 ! "
"ffmpegcolorspace ! video/x-raw-rgb ! fakesink";
run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN);
/* Check that audioresample can pick a samplerate to use from a
* range that doesn't include the input */
s = "audiotestsrc ! audio/x-raw-int,width=16,depth=16,rate=8000 ! "
"audioresample ! audio/x-raw-int,rate=[16000,48000] ! fakesink";
run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN);
/* Check that audioconvert can pick a depth to use, given a width */
s = "audiotestsrc ! audio/x-raw-int,width=16,depth=16 ! audioconvert ! "
"audio/x-raw-int,width=32 ! fakesink";
run_pipeline (setup_pipeline (s), s,
GST_MESSAGE_ANY & ~(GST_MESSAGE_ERROR | GST_MESSAGE_WARNING),
GST_MESSAGE_UNKNOWN);
}
GST_END_TEST Suite *
simple_launch_lines_suite (void)
{
Suite *s = suite_create ("Pipelines");
TCase *tc_chain = tcase_create ("linear");
/* time out after 20s, not the default 3 */
tcase_set_timeout (tc_chain, 20);
suite_add_tcase (s, tc_chain);
// tcase_add_test (tc_chain, test_element_negotiation);
tcase_add_test (tc_chain, test_basetransform_based);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = simple_launch_lines_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;
}

2
common

@ -1 +1 @@
Subproject commit 8db4c613eb1aa57dc21d25a4b83b36e3cdedc5ca
Subproject commit f9f5f063728688cf455a1512d492b632c43963d7

View file

@ -615,7 +615,8 @@ tools/Makefile
pkgconfig/Makefile
pkgconfig/gstreamer-plugins-base.pc
pkgconfig/gstreamer-plugins-base-uninstalled.pc
check/Makefile
tests/Makefile
tests/check/Makefile
docs/Makefile
docs/libs/Makefile
docs/plugins/Makefile

View file

@ -14,9 +14,6 @@ a support library for audio elements
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### ENUM GstAudioFieldFlag ##### -->
<para>

View file

@ -14,9 +14,6 @@ interface for adjusting color balance settings
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstColorBalance ##### -->
<para>

View file

@ -14,6 +14,3 @@ gconf default elements support
</para>
<!-- ##### SECTION Stability_Level ##### -->

View file

@ -14,9 +14,6 @@ interface for elements that provide mixer operations
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstMixer ##### -->
<para>
@ -47,18 +44,12 @@ interface for elements that provide mixer operations
</para>
@parent:
@values:
@_gst_reserved:
<!-- ##### STRUCT GstMixerTrack ##### -->
<para>
</para>
@parent:
@label:
@flags:
<!-- ##### FUNCTION gst_mixer_list_tracks ##### -->
<para>

View file

@ -14,9 +14,6 @@ an implementation of an audio ringbuffer
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstRingBuffer ##### -->
<para>

View file

@ -14,9 +14,6 @@ interface for elements that provide tuner operations
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstTuner ##### -->
<para>

View file

@ -14,9 +14,6 @@ interface for setting/getting a Window on elements supporting it.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### STRUCT GstXOverlay ##### -->
<para>

View file

@ -1,6 +1,6 @@
include $(top_srcdir)/common/check.mak
CHECK_REGISTRY = $(top_builddir)/check/test-registry.xml
CHECK_REGISTRY = $(top_builddir)/tests/check/test-registry.xml
REGISTRY_ENVIRONMENT = \
GST_REGISTRY=$(CHECK_REGISTRY)
@ -33,15 +33,15 @@ check_PROGRAMS = \
elements/audiotestsrc \
elements/videotestsrc \
elements/volume \
generic/clock-selection \
generic/states \
pipelines/simple_launch_lines \
clocks/selection \
pipelines/simple-launch-lines
$(check_vorbis)
VALGRIND_TO_FIX = \
elements/audioresample \
generic/states \
pipelines/simple_launch_lines
pipelines/simple-launch-lines
# these tests don't even pass
noinst_PROGRAMS =

View file

@ -1,26 +0,0 @@
if USE_ALSA
ALSA_DIR=alsa
else
ALSA_DIR=
endif
# if HAVE_GTK
# EMBED_DIR=embed
# else
# EMBED_DIR=
# endif
SUBDIRS = \
$(ALSA_DIR) #seeking
DIST_SUBDIRS = \
alsa
GST_PLUGIN_PATH=$(shell cd $(top_builddir) && pwd)
#$(TESTS):
# @echo -e '\nrunning gst-register...\n'
# $(GST_TOOLS_DIR)/gst-register --gst-plugin-path=$(GST_PLUGIN_PATH)
#TESTS=$(GST_TOOLS_DIR)/gst-compprep
.PHONY: $(TESTS)

View file

@ -1,3 +0,0 @@
formats
srcstate
state

View file

@ -1,13 +0,0 @@
testprogs = formats state srcstate
noinst_PROGRAMS = $(testprogs)
formats_SOURCES = formats.c sinesrc.c sinesrc.h
state_SOURCES = state.c sinesrc.c sinesrc.h
srcstate_SOURCES =srcstate.c
# we have nothing but apps here, we can do this safely
LIBS = $(GST_LIBS)
AM_CFLAGS = $(GST_CFLAGS)
noinst_HEADERS = sinesrc.h

View file

@ -1,183 +0,0 @@
/*
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* formats.c: Tests the different formats on alsasink
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "sinesrc.h"
GstElement *pipeline;
gint channels = 1;
gboolean sign = FALSE;
gint endianness = G_LITTLE_ENDIAN;
gint depth = 8;
gint width = 8;
#define NUMBER_OF_INT_TESTS 28
#define NUMBER_OF_FLOAT_TESTS 2
#define NUMBER_OF_LAW_TESTS 2
gint last = 0;
gint counter = 0;
static void create_pipeline (void);
static void
pre_get_func (SineSrc * src)
{
counter++;
};
static void
create_pipeline (void)
{
GstElement *src;
SineSrc *sinesrc;
GstElement *alsasink;
pipeline = gst_pipeline_new ("pipeline");
src = sinesrc_new ();
alsasink = gst_element_factory_make ("alsasink", "alsasink");
gst_bin_add_many (GST_BIN (pipeline), src, alsasink, NULL);
gst_element_link (src, alsasink);
/* prepare our sinesrc */
sinesrc = (SineSrc *) src;
sinesrc->pre_get_func = pre_get_func;
sinesrc->newcaps = TRUE;
/* int tests */
if (last < NUMBER_OF_INT_TESTS) {
sinesrc->type = SINE_SRC_INT;
sinesrc->sign = ((last % 2) == 0) ? TRUE : FALSE;
sinesrc->endianness =
((last / 2) % 2 == 0) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN;
switch ((last / 4) % 8) {
case 0:
sinesrc->depth = 8;
sinesrc->width = 8;
break;
case 1:
sinesrc->depth = 16;
sinesrc->width = 16;
break;
case 2:
sinesrc->depth = 24;
sinesrc->width = 32;
break;
case 3:
sinesrc->depth = 32;
sinesrc->width = 32;
break;
/* nomore tests below until i know what 24bit width means to alsa wrt endianness */
case 4:
sinesrc->depth = 24;
sinesrc->width = 24;
break;
case 5:
sinesrc->depth = 20;
sinesrc->width = 24;
break;
case 6:
sinesrc->depth = 18;
sinesrc->width = 24;
break;
case 7:
/* not used yet */
sinesrc->depth = 8;
sinesrc->width = 8;
break;
default:
g_assert_not_reached ();
}
g_print ("Setting format to: format: \"int\"\n"
" sign: %s\n"
" endianness: %d\n"
" width: %d\n"
" depth: %d\n",
sinesrc->sign ? "TRUE" : "FALSE", sinesrc->endianness,
sinesrc->width, sinesrc->depth);
} else if (last < NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS) {
gint temp = last - NUMBER_OF_INT_TESTS;
sinesrc->type = SINE_SRC_FLOAT;
switch (temp) {
case 0:
sinesrc->width = 32;
break;
case 1:
sinesrc->width = 64;
break;
default:
g_assert_not_reached ();
}
g_print ("Setting format to float width %d\n", sinesrc->width);
} else if (last <
NUMBER_OF_INT_TESTS + NUMBER_OF_FLOAT_TESTS + NUMBER_OF_LAW_TESTS) {
gint temp = last - NUMBER_OF_INT_TESTS - NUMBER_OF_FLOAT_TESTS;
GstElement *law;
sinesrc->type = SINE_SRC_INT;
sinesrc->sign = TRUE;
sinesrc->endianness = G_BYTE_ORDER;
sinesrc->depth = 16;
sinesrc->width = 16;
if (temp == 0) {
law = gst_element_factory_make ("mulawenc", "mulaw");
} else {
law = gst_element_factory_make ("alawenc", "alaw");
}
g_assert (law);
gst_element_unlink (src, alsasink);
gst_bin_add (GST_BIN (pipeline), law);
gst_element_link_many (src, law, alsasink, NULL);
if (temp == 0) {
g_print ("Setting format to: format: \"MU law\"\n");
} else {
g_print ("Setting format to: format: \"A law\"\n");
}
} else {
g_print ("All formats work like a charm.\n");
exit (0);
}
gst_element_set_state (pipeline, GST_STATE_PLAYING);
}
gint
main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
g_print ("\n"
"This test will test the various formats ALSA and GStreamer support.\n"
"You will hear a short sine tone on your default ALSA soundcard for every\n"
"format tested. They should all sound the same (incl. volume).\n" "\n");
create_pipeline ();
while (pipeline) {
gst_bin_iterate (GST_BIN (pipeline));
if ((counter / 200) > last) {
last = counter / 200;
gst_object_unref (pipeline);
create_pipeline ();
}
}
return 0;
}

View file

@ -1,349 +0,0 @@
/*
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* sinesrc.c: An elemnt emitting a sine src in lots of different formats
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "sinesrc.h"
#include <math.h>
#include <string.h> /* memcpy */
#define SAMPLES_PER_WAVE 200
static GstStaticPadTemplate sinesrc_src_factory =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, "
"signed = (boolean) { FALSE, TRUE }, "
"width = (int) [8, 32], "
"depth = (int) [8, 32], "
"rate = (int) [8000, 192000], "
"channels = (int) [1, 16];"
"audio/x-raw-float, "
"endianness = (int) BYTE_ORDER, "
"width = (int) {32, 64}, "
"rate = (int) [8000, 192000], " "channels = (int) [1, 16]")
);
static GstElementClass *parent_class = NULL;
static void sinesrc_init (SineSrc * src);
static void sinesrc_class_init (SineSrcClass * klass);
static GstData *sinesrc_get (GstPad * pad);
static GstStateChangeReturn sinesrc_change_state (GstElement * element,
GstStateChange transition);
GType
sinesrc_get_type (void)
{
static GType sinesrc_type = 0;
if (!sinesrc_type) {
static const GTypeInfo sinesrc_info = {
sizeof (SineSrcClass), NULL, NULL,
(GClassInitFunc) sinesrc_class_init, NULL, NULL,
sizeof (SineSrc), 0,
(GInstanceInitFunc) sinesrc_init,
};
sinesrc_type = g_type_register_static (GST_TYPE_ELEMENT, "SineSrc",
&sinesrc_info, 0);
}
return sinesrc_type;
}
static void
sinesrc_class_init (SineSrcClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
element_class->change_state = sinesrc_change_state;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
}
static void
sinesrc_init (SineSrc * src)
{
src->src =
gst_pad_new_from_template (gst_static_pad_template_get
(&sinesrc_src_factory), "src");
gst_element_add_pad (GST_ELEMENT (src), src->src);
gst_pad_set_get_function (src->src, sinesrc_get);
src->width = 16;
src->depth = 16;
src->sign = TRUE;
src->endianness = G_BYTE_ORDER;
src->rate = 44100;
src->channels = 1;
src->type = SINE_SRC_INT;
src->newcaps = TRUE;
src->pre_get_func = NULL;
GST_OBJECT (src)->name = "sinesrc";
}
static void
sinesrc_force_caps (SineSrc * src)
{
GstCaps *caps;
if (!src->newcaps)
return;
src->newcaps = FALSE;
switch (src->type) {
case SINE_SRC_INT:
caps = gst_caps_new_simple ("audio/x-raw-int",
"signed", G_TYPE_BOOLEAN, src->sign,
"depth", G_TYPE_INT, src->depth, NULL);
if (src->width > 8)
gst_caps_set_simple (caps,
"endianness", G_TYPE_INT, src->endianness, NULL);
break;
case SINE_SRC_FLOAT:
g_assert (src->width == 32 || src->width == 64);
caps = gst_caps_new_simple ("audio/x-raw-float",
"endianness", G_TYPE_INT, src->endianness, NULL);
break;
default:
caps = NULL;
g_assert_not_reached ();
}
gst_caps_set_simple (caps,
"width", G_TYPE_INT, src->width,
"rate", G_TYPE_INT, src->rate,
"channels", G_TYPE_INT, src->channels, NULL);
if (gst_pad_try_set_caps (src->src, caps) != GST_PAD_LINK_OK)
g_assert_not_reached ();
}
/* always return 1 wave
* there are 200 waves in 1 second, so the frequency is samplerate/200
*/
static guint8
UIDENTITY (guint8 x)
{
return x;
};
static gint8
IDENTITY (gint8 x)
{
return x;
};
#define POPULATE(format, be_func, le_func) G_STMT_START {\
format val = (format) int_value;\
format *p = data;\
switch (src->endianness) {\
case G_LITTLE_ENDIAN:\
val = le_func (val);\
break;\
case G_BIG_ENDIAN:\
val = be_func (val);\
break;\
default: \
g_assert_not_reached ();\
};\
for (j = 0; j < src->channels; j++) {\
*p = val;\
p ++;\
}\
data = p;\
} G_STMT_END
static GstData *
sinesrc_get (GstPad * pad)
{
GstBuffer *buf;
SineSrc *src;
void *data;
gint i, j;
gdouble value;
g_return_val_if_fail (pad != NULL, NULL);
src = SINESRC (gst_pad_get_parent (pad));
if (src->pre_get_func)
src->pre_get_func (src);
buf = gst_buffer_new_and_alloc ((src->width / 8) * src->channels *
SAMPLES_PER_WAVE);
g_assert (buf);
data = GST_BUFFER_DATA (buf);
g_assert (data);
for (i = 0; i < SAMPLES_PER_WAVE; i++) {
value = sin (i * 2 * M_PI / SAMPLES_PER_WAVE);
switch (src->type) {
case SINE_SRC_INT:{
gint64 int_value =
(value + (src->sign ? 0 : 1)) * (((guint64) 1) << (src->depth - 1));
if (int_value ==
(1 + (src->sign ? 0 : 1)) * (((guint64) 1) << (src->depth - 1)))
int_value--;
switch (src->width) {
case 8:
if (src->sign)
POPULATE (gint8, IDENTITY, IDENTITY);
else
POPULATE (guint8, UIDENTITY, UIDENTITY);
break;
case 16:
if (src->sign)
POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE);
else
POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE);
break;
case 24:
if (src->sign) {
gpointer p;
gint32 val = (gint32) int_value;
switch (src->endianness) {
case G_LITTLE_ENDIAN:
val = GINT32_TO_LE (val);
break;
case G_BIG_ENDIAN:
val = GINT32_TO_BE (val);
break;
default:
g_assert_not_reached ();
};
p = &val;
if (src->endianness == G_BIG_ENDIAN)
p++;
for (j = 0; j < src->channels; j++) {
memcpy (data, p, 3);
data += 3;
}
} else {
gpointer p;
guint32 val = (guint32) int_value;
switch (src->endianness) {
case G_LITTLE_ENDIAN:
val = GUINT32_TO_LE (val);
break;
case G_BIG_ENDIAN:
val = GUINT32_TO_BE (val);
break;
default:
g_assert_not_reached ();
};
p = &val;
if (src->endianness == G_BIG_ENDIAN)
p++;
for (j = 0; j < src->channels; j++) {
memcpy (data, p, 3);
data += 3;
}
}
break;
case 32:
if (src->sign)
POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE);
else
POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE);
break;
default:
g_assert_not_reached ();
}
break;
}
case SINE_SRC_FLOAT:
if (src->width == 32) {
gfloat *p = (gfloat *) data;
gfloat fval = (gfloat) value;
for (j = 0; j < src->channels; j++) {
*p = fval;
p++;
}
data = p;
break;
}
if (src->width == 64) {
gdouble *p = (gdouble *) data;
for (j = 0; j < src->channels; j++) {
*p = value;
p++;
}
data = p;
break;
}
g_assert_not_reached ();
default:
g_assert_not_reached ();
}
}
if (src->newcaps) {
sinesrc_force_caps (src);
}
return GST_DATA (buf);
}
GstElement *
sinesrc_new (void)
{
return GST_ELEMENT (g_object_new (TYPE_SINESRC, NULL));
}
void
sinesrc_set_pre_get_func (SineSrc * src, PreGetFunc func)
{
src->pre_get_func = func;
}
static GstStateChangeReturn
sinesrc_change_state (GstElement * element, GstStateChange transition)
{
SineSrc *sinesrc;
g_return_val_if_fail (element != NULL, FALSE);
sinesrc = SINESRC (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
case GST_STATE_CHANGE_READY_TO_PAUSED:
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
sinesrc->newcaps = TRUE;
break;
case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
g_assert_not_reached ();
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
return GST_STATE_CHANGE_SUCCESS;
}

View file

@ -1,89 +0,0 @@
/*
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* sinesrc.h: Header file for sinesrc.c
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SINESRC_H__
#define __SINESRC_H__
#include <gst/gst.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define TYPE_SINESRC \
(sinesrc_get_type())
#define SINESRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),TYPE_SINESRC,SineSrc))
#define SINESRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),TYPE_SINESRC,SineSrcClass))
#define IS_SINESRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),TYPE_SINESRC))
#define IS_SINESRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),TYPE_SINESRC))
typedef struct _SineSrc SineSrc;
typedef struct _SineSrcClass SineSrcClass;
typedef void (*PreGetFunc) (SineSrc *src);
typedef enum {
SINE_SRC_INT,
SINE_SRC_FLOAT
} SineSrcAudio;
struct _SineSrc {
GstElement element;
/* pads */
GstPad *src;
/* audio parameters */
SineSrcAudio type;
gint width; /* int + float */
gint depth; /* int */
gboolean sign; /* int */
gint endianness; /* int */
gint rate;
gint channels; /* interleaved */
gboolean newcaps;
/* freaky stuff for testing */
PreGetFunc pre_get_func;
};
struct _SineSrcClass {
GstElementClass parent_class;
};
GType sinesrc_get_type (void);
GstElement * sinesrc_new (void);
void sinesrc_set_pre_get_func (SineSrc *src, PreGetFunc func);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GST_SINESRC_H__ */

View file

@ -1,95 +0,0 @@
/*
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* srcstate.c: Tests alsasrc for state changes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gst/gst.h>
GstElement *pipeline;
static void
set_state (GstState state)
{
GstState old_state = gst_element_get_state (pipeline);
g_print ("Setting state from %s to %s...",
gst_element_state_get_name (old_state),
gst_element_state_get_name (state));
if (!gst_element_set_state (pipeline, state)) {
g_print (" ERROR\n");
exit (-1);
}
if (state == GST_STATE_PLAYING) {
gint i;
g_print (" DONE - iterating a bit...");
for (i = 0; i < 5; i++) {
if (!gst_bin_iterate (GST_BIN (pipeline))) {
g_print (" ERROR in iteration %d\n", i);
exit (-2);
}
}
}
g_print (" DONE\n");
}
static void
create_pipeline (void)
{
GstElement *alsasrc;
GstElement *fakesink;
pipeline = gst_pipeline_new ("pipeline");
alsasrc = gst_element_factory_make ("alsasrc", "alsasrc");
fakesink = gst_element_factory_make ("fakesink", "fakesink");
gst_bin_add_many (GST_BIN (pipeline), alsasrc, fakesink, NULL);
gst_element_link (alsasrc, fakesink);
}
gint
main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
g_print ("\n" "This test will check if state changes work on the alsasrc.\n");
create_pipeline ();
/* simulate some state changes here */
set_state (GST_STATE_READY);
set_state (GST_STATE_NULL);
set_state (GST_STATE_READY);
set_state (GST_STATE_NULL);
set_state (GST_STATE_PAUSED);
set_state (GST_STATE_NULL);
set_state (GST_STATE_PLAYING);
set_state (GST_STATE_PAUSED);
set_state (GST_STATE_PLAYING);
set_state (GST_STATE_READY);
set_state (GST_STATE_PLAYING);
set_state (GST_STATE_NULL);
set_state (GST_STATE_PLAYING);
g_print ("The alsa plugin mastered another test.\n");
gst_object_unref (pipeline);
return 0;
}

View file

@ -1,108 +0,0 @@
/*
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
*
* state.c: Tests alsasink for state changes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "sinesrc.h"
GstElement *pipeline;
static void
set_state (GstState state)
{
GstState old_state = gst_element_get_state (pipeline);
g_print ("Setting state from %s to %s...",
gst_element_state_get_name (old_state),
gst_element_state_get_name (state));
if (!gst_element_set_state (pipeline, state)) {
g_print (" ERROR\n");
exit (-1);
}
if (state == GST_STATE_PLAYING) {
gint i;
g_print (" DONE - iterating a bit...");
for (i = 0; i < 400; i++) {
if (!gst_bin_iterate (GST_BIN (pipeline))) {
g_print (" ERROR in iteration %d\n", i);
exit (-2);
}
}
}
g_print (" DONE\n");
}
static void
create_pipeline (void)
{
GstElement *src;
SineSrc *sinesrc;
GstElement *alsasink;
pipeline = gst_pipeline_new ("pipeline");
src = sinesrc_new ();
alsasink = gst_element_factory_make ("alsasink", "alsasink");
gst_bin_add_many (GST_BIN (pipeline), src, alsasink, NULL);
gst_element_link (src, alsasink);
/* prepare our sinesrc */
sinesrc = (SineSrc *) src;
sinesrc->newcaps = TRUE;
sinesrc->type = SINE_SRC_INT;
sinesrc->sign = TRUE;
sinesrc->endianness = G_BYTE_ORDER;
sinesrc->depth = 16;
sinesrc->width = 16;
}
gint
main (gint argc, gchar * argv[])
{
gst_init (&argc, &argv);
g_print ("\n"
"This test will check if state changes work on the alsasink.\n"
"You will hear some short sine tones on your default ALSA soundcard,\n"
"but they are not important in this test.\n" "\n");
create_pipeline ();
/* simulate some state changes here */
set_state (GST_STATE_READY);
set_state (GST_STATE_NULL);
set_state (GST_STATE_READY);
set_state (GST_STATE_NULL);
set_state (GST_STATE_PAUSED);
set_state (GST_STATE_NULL);
set_state (GST_STATE_PLAYING);
set_state (GST_STATE_PAUSED);
set_state (GST_STATE_PLAYING);
set_state (GST_STATE_READY);
set_state (GST_STATE_PLAYING);
set_state (GST_STATE_NULL);
set_state (GST_STATE_PLAYING);
g_print ("The alsa plugin mastered another test.\n");
gst_object_unref (pipeline);
return 0;
}

View file

@ -1,7 +0,0 @@
noinst_PROGRAMS = embed
# we have nothing but apps here, we can do this safely
LIBS = $(GST_LIBS) $(GTK_LIBS) \
$(top_builddir)/gst-libs/gst/libgstinterfaces-$(GST_MAJORMINOR).la
AM_CFLAGS = $(GST_CFLAGS) $(GTK_CFLAGS)

View file

@ -1,54 +0,0 @@
/*
* Sample app for element embedding.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/xoverlay/xoverlay.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
static void
cb_expose (GtkWidget * w, GdkEventExpose * ev, GstElement * e)
{
if (GST_IS_X_OVERLAY (e) &&
!GTK_WIDGET_NO_WINDOW (w) && GTK_WIDGET_REALIZED (w)) {
gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (e),
GDK_WINDOW_XWINDOW (w->window));
}
}
int
main (int argc, char *argv[])
{
GtkWidget *window, *content;
GstElement *testsrc, *csp, *videosink, *pipeline;
gtk_init (&argc, &argv);
gst_init (&argc, &argv);
pipeline = gst_element_factory_make ("pipeline", NULL);
testsrc = gst_element_factory_make ("videotestsrc", NULL);
csp = gst_element_factory_make ("ffmpegcolorspace", NULL);
videosink = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
gtk_window_set_title (GTK_WINDOW (window), "My application");
content = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (window), content);
g_signal_connect (content, "expose-event", G_CALLBACK (cb_expose), videosink);
gtk_widget_show_all (window);
gst_bin_add_many (GST_BIN (pipeline), testsrc, csp, videosink, NULL);
gst_element_link_many (testsrc, csp, videosink, NULL);
g_idle_add ((GSourceFunc) gst_bin_iterate, pipeline);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gtk_main ();
return 0;
}

View file

@ -1,571 +0,0 @@
#!/usr/bin/perl -w
# vi: set ts=4:
#
#
# GStreamer developers: please add comments on any tests you think
# are dumb or have too many false positives.
#
#
# Future ideas:
# - spell check comments
# - check each function for at least one assertion (?)
# - check parameters that init/set/get have consistent types
# - check for gst_caps_set() without check for writeability
# - check .so files for stray symbols
#
#
# Random "other" testing ideas
# - load each plugin individually
#
sub check_copyright();
sub check_license();
sub check_buffer_alloc();
sub check_bad_includes();
sub check_begin_decls();
sub check_c99_comments();
sub check_carriage_returns();
sub check_printf_lld();
sub check_glibisms();
sub check_indentation();
sub check_no_ignore();
sub check_deprecated();
sub check_config_h();
sub check_varargs_functions();
sub check_debugging();
sub check_old_typefind();
sub check_bad_casts();
sub check_old_plugin();
sub check_signal_new();
sub check_gnuc_const();
sub check_caps();
sub check_lib_deprecated();
sub check_typo();
sub check_explicit_caps();
sub check_signals();
sub check_gettext();
sub check_padtemplate();
sub check_parent_class();
sub m_check_plugindir();
sub m_check_interfaces();
open FIND, "find . -name \"*.[ch]\" -print|";
foreach $filename (<FIND>) {
chomp $filename;
open FILE, "$filename";
@lines = <FILE>;
close FILE;
print "I: $filename\n";
# important stuff
check_bad_includes();
check_printf_lld();
check_no_ignore();
check_deprecated();
check_config_h();
check_old_typefind();
check_old_plugin();
check_caps();
check_lib_deprecated();
check_typo();
check_glibisms();
check_explicit_caps();
check_signals();
check_gettext();
check_padtemplate();
check_parent_class();
# less important stuff
check_license();
if (0) {
check_copyright();
check_gnuc_const();
check_begin_decls();
check_buffer_alloc();
check_c99_comments();
check_carriage_returns();
#check_indentation();
check_varargs_functions();
check_debugging();
check_bad_casts();
check_signal_new();
}
}
open FIND, "find . -name \"Makefile.am\" -print|";
foreach $filename (<FIND>) {
chomp $filename;
open FILE, "$filename";
@lines = <FILE>;
close FILE;
print "I: $filename\n";
m_check_plugindir();
m_check_interfaces();
}
#
# Every source file must have a copyright block
#
sub check_copyright()
{
if (! grep { /copyright/i; } @lines) {
print "E: no copyright block\n";
}
}
#
# Every source file should have a license statement
#
sub check_license()
{
if (grep { /Lesser General Public License/; } @lines) {
print "I: license is LGPL\n";
} elsif (grep { /Library General Public License/; } @lines) {
print "I: license is LGPL\n";
print "W: copyright header uses \"Library\" LGPL\n";
} elsif (grep { /General Public License/; } @lines) {
print "I: license is GPL\n";
} else {
print "E: unknown license or no copyright block\n";
}
}
#
# Suggest usage of gst_buffer_new_and_alloc()
#
sub check_buffer_alloc()
{
my $n = 0;
my $lineno = 1;
foreach $line (@lines){
if($line =~ /gst_buffer_new/){
$n=5;
}
if($n>0 && $line =~ /malloc/){
print "W: ($lineno) gst_buffer_new() followed by malloc(), suggest gst_buffer_new_and_alloc()\n";
return;
}
$n--;
$lineno++;
}
}
sub check_bad_includes()
{
#
# malloc.h is non-standard (and probably not what is indended)
#
if (grep { /^#include\s+<malloc.h>/; } @lines) {
print "E: bad header: malloc.h\n"
}
}
sub check_begin_decls()
{
#
# Prefer "G_BEGIN_DECLS" to 'extern "C" {'
#
if($filename =~ /\.h$/){
if (grep { /extern\s*\"C\"\s*/; } @lines) {
print "W: extern \"C\" { should be changed to G_BEGIN_DECLS,G_END_DECLS\n";
}elsif (!grep { /G_BEGIN_DECLS/; } @lines) {
print "E: header doesn't use G_BEGIN_DECLS\n";
}
}
}
#
# Prefer c89-style comments
#
sub check_c99_comments()
{
if (grep { /\/\//; } @lines) {
print "W: //-style comments should be converted to /* */\n"
}
}
#
# DOS end-of-line characters are just wrong
#
sub check_carriage_returns()
{
if (grep { /\r/; } @lines) {
print "E: source has carriage returns (DOS-style files)\n"
}
}
#
# Many uses of %lld are wrong. This could have a lot of false-positives
#
sub check_printf_lld()
{
if (grep { /\".*\%\d*ll[du].*\"/; } @lines) {
print "W: Possible \%lld or \%llu in printf format\n"
}
}
#
# Glib functions are preferred
#
sub check_glibisms()
{
if (grep { /\bcalloc\s*\(/; } @lines) {
print "E: use g_malloc0() instead of calloc()\n"
}
if (grep { /\bfree\s*\(/; } @lines) {
print "E: use g_free() instead of free()\n"
}
if (grep { /\bmalloc\s*\(/; } @lines) {
print "E: use g_malloc() instead of malloc()\n"
}
if (grep { /\bprintf\s*\(/; } @lines) {
print "E: use g_print() instead of printf()\n"
}
if (grep { /\brealloc\s*\(/; } @lines) {
print "E: use g_realloc() instead of realloc()\n"
}
if (grep { /^#include\s+<ctype.h>/; } @lines) {
print "E: ctype.h functions are not locale-independent and don't work in UTF-8 locales. Use g_ascii_is*()\n"
}
}
#
# I don't think that indentation necessarily needs to be fixed, since
# it causes problems with patching and cvs annotate.
#
# This takes forever and isn't very useful
#
sub check_indentation()
{
my $changed_lines;
my $percent;
`indent -br -bad -cbi0 -cli2 -bls -l80 -ut -ce $filename -o .check_plugin.tmp`;
$changed_lines = `diff $filename .check_plugin.tmp | grep '^>' | wc -l`;
`rm -f .check_plugin.tmp`;
$percent = int(100 * $changed_lines / $#lines);
if($percent < 10){
print "I: indent changed $percent % of the lines\n";
}elsif($percent <20){
print "W: indent changed $percent % of the lines\n";
}else{
print "E: indent changed $percent % of the lines\n";
}
}
#
# Check (roughly) for functions whose value should not be ignored
#
sub check_no_ignore()
{
if (grep { /^\s+gst_buffer_merge\s*\(/; } @lines) {
print "E: return value of gst_buffer_merge () possibly ignored\n";
}
if (grep { /^\s+malloc\s*\(/; } @lines) {
print "E: return value of malloc() possibly ignored\n";
}
if (grep { /^\s+gst_buffer_new\s*\(/; } @lines) {
print "E: return value of gst_buffer_new() possibly ignored\n";
}
}
#
# Check for some deprecated stuff (that _shouldn't_ be around anymore)
#
sub check_deprecated()
{
#
# Check for old GST_DEBUG() usage
# (none found)
#
if (grep { /GST_DEBUG\s*\(\s+\d/; } @lines) {
print "E: old-style GST_DEBUG()\n";
}
if (grep { /GST_INFO\s*\(\s+\d/; } @lines) {
print "E: old-style GST_DEBUG()\n";
}
if (grep { /GstEventFlags/; } @lines) {
print "W: who uses GstEventFlags\n";
}
if (grep { /g_type_class_ref/ } @lines) {
print "W: g_type_class_ref should be changed to g_type_class_peek_parent\n";
}
}
#
# Every .c file should include config.h before any other headers
# No .h file should include config.h
#
sub check_config_h()
{
if($filename =~ /\.c$/){
#
# config.h should be wrapped
#
my @includes = grep { /^#include/; } @lines;
if (!grep { /^#include\s+["<]config.h[">]/; } @includes) {
print "E: #include <config.h> missing\n";
}else{
if (!($includes[0] =~ /^#include\s+["<]config.h[">]/)){
print "E: #include <config.h> is not first include\n";
}
if(!grep { /^#ifdef HAVE_CONFIG_H/; } @lines) {
print "E: #include <config.h> not surrounded by #ifdef HAVE_CONFIG_H\n";
}
}
}
if($filename =~ /\.h$/){
if (grep { /^#include\s+["<]config.h[">]/; } @lines) {
print "E: headers should not #include <config.h>\n";
}
}
}
#
# Check for functions that take varargs to make sure they are
# named correctly
#
sub check_varargs_functions()
{
if($filename =~ /\.h$/){
if (grep { /varargs/; } @lines) {
print "I: has varargs\n";
}
}
}
#
# Debugging checks
#
sub check_debugging()
{
if (grep { /\Wg_print\W/ || /\Wprintf\W/ && /\Wfprintf\W/; } @lines) {
print "W: friendly libraries don't print to stdio or stderr\n";
}
if (grep { /GST_DEBUG.*\\n"/; } @lines) {
print "W: possible newline in GST_DEBUG()\n";
}
}
#
# check for plugindir=
#
sub m_check_plugindir()
{
if (grep { /plugindir\s*=/; } @lines) {
print "E: plugindir= is no longer necessary\n";
}
}
#
# check for old typefinding code
#
sub check_old_typefind()
{
if (grep { /GstTypeDefinition/ || /GstTypeFactory/ } @lines) {
print "E: old typefind interface has been removed\n";
}
}
#
# check for casts that we've deemed incorrect (fix the prototype)
#
sub check_bad_casts()
{
if (grep { /GBaseInitFunc/ || /GBaseFinalizeFunc/ ||
/GClassInitFunc/ || /GClassFinalizeFunc/ ||
/GInstanceInitFunc/ || /GInterfaceInitFunc/ ||
/GInterfaceFinalizeFunc/ } @lines) {
print "W: bad casts (fix prototype)\n";
}
if (grep { /\(\s*Gst[A-Z][A-Za-z]*\s*\*\s*\)/ } @lines ) {
print "W: use GST_XXX() instead of (GstXxx *)\n";
}
}
#
# check for old plugin code
#
sub check_old_plugin()
{
if (grep { /plugin_init.*GModule.*GstPlugin/ } @lines) {
print "E: old plugin interface detected\n";
}
if (grep { /GstPluginDesc.*plugin_desc/ } @lines) {
print "W: should use GST_PLUGIN_DEFINE() instead of GstPluginDesc\n";
}
}
#
# Check for calls to g_signal_new() with a callback type of G_TYPE_POINTER
#
sub check_signal_new()
{
my $n = 0;
my $lineno = 1;
foreach $line (@lines){
if($line =~ /g_signal_new/){
$n=5;
}
if($n>0 && $line =~ /G_TYPE_POINTER/){
print "W: ($lineno) g_signal_new() with callback type of G_TYPE_POINTER. Register and use a boxed type instead.\n";
return;
}
$n--;
$lineno++;
}
}
#
# Check that libgstinterfaces is in LDADD
#
sub m_check_interfaces()
{
if (grep { /libgstinterfaces.la/ } @lines) {
if (! grep { /libgstinterfaces_la/ } @lines) {
if (! grep { /_LDADD.*libgstinterfaces.la/ } @lines) {
print "E: libgstinterfaces.la not in LDADD\n";
}
}
}
}
#
# Check that get_type() functions return G_CONST_RETURN GType
#
sub check_gnuc_const()
{
my $n = 0;
my $lineno = 1;
foreach $line (@lines){
if($line =~ /GType.*get_type.*/ &&
!($line =~ /GType.*get_type.*G_GNUC_CONST/)) {
print "E: get_type function does not have G_GNUC_CONST attribute\n";
}
}
}
#
# Check caps usage
#
sub check_caps()
{
if (grep { /gst_pad_get_caps/ } @lines) {
print "E: elements should not call gst_pad_get_caps(), use gst_pad_get_allowed_caps()\n";
}
}
#
# Check for use of deprecated functions
#
sub check_lib_deprecated()
{
if (grep { /bzero/ } @lines) {
print "E: change bzero() to memset()\n";
}
}
#
# Check for typos
#
sub check_typo()
{
if (grep { /;\s*;\s*$/ } @lines) {
print "W: typo? \";;\"\n";
}
}
#
# set_explicit_caps() should preceed pad_add()
#
sub check_explicit_caps()
{
my $n = 0;
my $lineno = 1;
foreach $line (@lines){
if($line =~ /gst_element_add_pad/){
$n=10;
}
if($n>0 && $line =~ /gst_pad_set_explicit_caps/){
print "W: ($lineno) explicit caps should be set before adding pad\n";
return;
}
$n--;
$lineno++;
}
}
#
# Check for - in signal names
#
sub check_signals()
{
if (grep { /g_signal_new.*\".*-.*\"/; } @lines) {
print "E: g_signal_new() with a signal name with a - in it (we prefer _)\n"
}
}
#
# Check for things that gettext gets wrong
#
sub check_gettext()
{
if (grep { /\b_\(.*G_GU?INT64_FORMAT/ ||
/\b_\(.*GST_TIME_FORMAT/ ||
/\b_\(.*GST_FOURCC_FORMAT/ } @lines) {
print "E: gettext doesn't handle format strings that are defines\n"
}
}
#
# Check that pad templates are statically scoped
#
sub check_padtemplate()
{
foreach $line (@lines){
if ($line =~ /GstStaticPadTemplate/ && !($line =~ /static/)) {
print "W: pad template definitions should be static\n";
return;
}
}
}
#
# Check that parent_class is statically scoped
#
sub check_parent_class()
{
foreach $line (@lines){
if ($line =~ /Gst.*\*\s*parent_class/ && !($line =~ /static/)) {
print "E: parent_class definitions should be static\n";
return;
}
}
}