move under tests

Original commit message from CVS:
move under tests
parent aab214c9
2005-11-30 Thomas Vander Stichele <thomas (at) apestaart (dot) org>
* Makefile.am:
* check/.cvsignore:
* check/Makefile.am:
* check/elements/.cvsignore:
* check/elements/level.c:
* check/elements/matroskamux.c:
* configure.ac:
* examples/Makefile.am:
* examples/capsfilter/Makefile.am:
* examples/capsfilter/capsfilter1.c:
* examples/gob/Makefile.am:
* examples/gob/gst-identity2.gob:
* examples/gstplay/.cvsignore:
* examples/gstplay/Makefile.am:
* examples/gstplay/player.c:
* examples/indexing/.cvsignore:
* examples/indexing/Makefile.am:
* examples/indexing/indexmpeg.c:
* examples/level/Makefile.am:
* examples/level/README:
* examples/level/demo.c:
* examples/level/plot.c:
* examples/stats/Makefile.am:
* examples/stats/mp2ogg.c:
* examples/switch/.cvsignore:
* examples/switch/Makefile.am:
* examples/switch/switcher.c:
move under tests/
2005-11-30 Tim-Philipp Müller <tim at centricular dot net>
* ext/pango/gsttextrender.c: (gst_text_render_base_init),
......
......@@ -6,12 +6,6 @@ else
GCONF_DIR =
endif
if HAVE_CHECK
SUBDIRS_CHECK = check
else
SUBDIRS_CHECK =
endif
ALWAYS_SUBDIRS = \
gst sys ext \
docs \
......@@ -20,12 +14,10 @@ ALWAYS_SUBDIRS = \
SUBDIRS = \
$(ALWAYS_SUBDIRS) \
$(SUBDIRS_CHECK) \
$(GCONF_DIR)
DIST_SUBDIRS = \
$(ALWAYS_SUBDIRS) \
check \
gconf
EXTRA_DIST = \
......@@ -45,7 +37,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
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
.dirstamp
level
matroskamux
/* 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;
}
This diff is collapsed.
......@@ -578,7 +578,7 @@ gconf/gstreamer.schemas
docs/Makefile
docs/plugins/Makefile
docs/version.entities
check/Makefile
tests/check/Makefile
common/Makefile
common/m4/Makefile
m4/Makefile
......
if HAVE_GTK
GTK_SUBDIRS=dynparams level $(FT2_SUBDIRS)
else
GTK_SUBDIRS=
endif
if USE_GCONF
GCONF_SUBDIRS=gstplay
else
GCONF_SUBDIRS=
endif
SUBDIRS=$(GTK_SUBDIRS) $(GCONF_SUBDIRS) switch
DIST_SUBDIRS=capsfilter dynparams indexing gstplay switch level
noinst_PROGRAMS = capsfilter1
LDADD = $(GST_LIBS)
AM_CFLAGS = $(GST_CFLAGS)
#include <string.h>
#include <gst/gst.h>
/* This app uses a filter to connect colorspace and videosink
* so that only RGB data can pass the connection, colorspace will use
* a converter to convert the I420 data to RGB. Without a filter, this
* connection would use the I420 format (assuming Xv is enabled) */
static void
new_pad_func (GstElement * element, GstPad * newpad, gpointer data)
{
GstElement *pipeline = (GstElement *) data;
GstElement *queue = gst_bin_get_by_name (GST_BIN (pipeline), "queue");
if (!strcmp (gst_pad_get_name (newpad), "video_00")) {
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gst_pad_link (newpad, gst_element_get_pad (queue, "sink"));
gst_element_set_state (pipeline, GST_STATE_PLAYING);
}
}
gint
main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *filesrc;
GstElement *demux;
GstElement *thread;
GstElement *queue;
GstElement *mpeg2dec;
GstElement *colorspace;
GstElement *videosink;
gboolean res;
gst_init (&argc, &argv);
if (argc < 2) {
g_print ("usage: %s <mpeg1 system stream>\n", argv[0]);
return (-1);
}
pipeline = gst_pipeline_new ("main_pipeline");
filesrc = gst_element_factory_make ("filesrc", "filesrc");
g_return_val_if_fail (filesrc, -1);
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
demux = gst_element_factory_make ("mpegdemux", "demux");
g_return_val_if_fail (demux, -1);
g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func),
pipeline);
thread = gst_thread_new ("thread");
queue = gst_element_factory_make ("queue", "queue");
mpeg2dec = gst_element_factory_make ("mpeg2dec", "mpeg2dec");
g_return_val_if_fail (mpeg2dec, -1);
colorspace = gst_element_factory_make ("ffmpegcolorspace", "colorspace");
g_return_val_if_fail (colorspace, -1);
videosink = gst_element_factory_make (DEFAULT_VIDEOSINK, "videosink");
g_return_val_if_fail (videosink, -1);
gst_bin_add (GST_BIN (pipeline), filesrc);
gst_bin_add (GST_BIN (pipeline), demux);
gst_bin_add (GST_BIN (thread), queue);
gst_bin_add (GST_BIN (thread), mpeg2dec);
gst_bin_add (GST_BIN (thread), colorspace);
gst_bin_add (GST_BIN (thread), videosink);
gst_bin_add (GST_BIN (pipeline), thread);
gst_element_link_pads (filesrc, "src", demux, "sink");
gst_element_link_pads (queue, "src", mpeg2dec, "sink");
gst_element_link_pads (mpeg2dec, "src", colorspace, "sink");
/* force RGB data passing between colorspace and videosink */
res = gst_element_link_pads_filtered (colorspace, "src", videosink, "sink",
gst_caps_new_simple ("video/x-raw-rgb", NULL));
if (!res) {
g_print ("could not connect colorspace and videosink\n");
return -1;
}
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
gst_element_set_state (pipeline, GST_STATE_NULL);
return 0;
}
plugin_LTLIBRARIES = libgstidentity2.la
GOB_FILES_ID = gst-identity2.c gst-identity2.h gst-identity2-private.h
BUILT_SOURCES = \
$(GOB_FILES_ID)
libgstidentity2_la_SOURCES = gst-identity2.gob $(GOB_FILES_ID)
libgstidentity2_la_CFLAGS = $(GST_CFLAGS)
libgstidentity2_la_LIBADD =
%.c %.h %-private.h: %.gob
gob $<
CLEANFILES = $(GOB_FILES_ID)
dist-hook:
cd $(distdir); rm -f $(CLEANFILES)
%header{
#include <gst/gst.h>
#include "gst-identity2.h"
#include "gst-identity2-private.h"
%}
class Gst:Identity2 from Gst:Element {
/* plugin init */
private gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
static GstElementDetails identity2_details = {
"GOB Identity",
"Filter/Effect",
"Does nothing",
"1.0",
"Wim Taymans <wim.taymans@chello.be>",
"(C) 2001",
};
GstElementFactory *factory;
factory = gst_elementfactory_new ("identity2", TYPE_SELF,
&identity2_details);
g_return_val_if_fail (factory != NULL, FALSE);
gst_plugin_add_feature (plugin, &(factory->feature));
return TRUE;
}
/* pads FIXME gob oculd be improved here */
private GstPad *sinkpad =
{
gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (o), o->_priv->sinkpad);
gst_pad_set_chain_function (o->_priv->sinkpad, chain);
gst_pad_set_bufferpool_function (o->_priv->sinkpad, get_bufferpool);
//gst_pad_set_negotiate_function (o->_priv->sinkpad, negotiate_sink);
};
private GstPad *srcpad =
{
gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (o), o->_priv->srcpad);
//gst_pad_set_negotiate_function (o->_priv->srcpad, negotiate_src);
};
/* arguments */
/*
private gboolean loop_based = FALSE; argument BOOL loop_based
get {
ARG = self->_priv->loop_based;
}
set {
self->_priv->loop_based = ARG;
if (self->_priv->loop_based) {
gst_element_set_loop_function (GST_ELEMENT (self), loop);
gst_pad_set_chain_function (self->_priv->sinkpad, NULL);
}
else {
gst_pad_set_chain_function (self->_priv->sinkpad, chain);
gst_element_set_loop_function (GST_ELEMENT (self), NULL);
}
};*/
private guint sleep_time = 0; argument UINT sleep_time link;
private gboolean silent = FALSE; argument BOOL silent link;
/* signals */
private signal last NONE(NONE) void handoff(self);
/* core code here */
private GstBufferPool*
get_bufferpool (GstPad *pad (check null))
{
Self *self = SELF (gst_pad_get_parent (pad));
return gst_pad_get_bufferpool (self->_priv->srcpad);
}
/* private GstPadNegotiateReturn
negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data)
{
Self *self = SELF (gst_pad_get_parent (pad));
return gst_pad_negotiate_proxy (pad, self->_priv->sinkpad, caps);
}
private GstPadNegotiateReturn
negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
{
Self *self = SELF (gst_pad_get_parent (pad));
return gst_pad_negotiate_proxy (pad, self->_priv->srcpad, caps);
} */
private void
chain (GstPad *pad (check null), GstBuffer *buf (check null))
{
Self *self;
self = SELF (gst_pad_get_parent (pad));
if (!self->_priv->silent)
g_print("identity2: chain ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(pad));
handoff (self);
gst_pad_push (self->_priv->srcpad, buf);
if (self->_priv->sleep_time)
usleep (self->_priv->sleep_time);
}
/*private void
loop (GstElement *element (check null))
{
Self *self = SELF (element);
GstBuffer *buf;
do {
buf = gst_pad_pull (self->_priv->sinkpad);
g_print("identity2: loop ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(self->_priv->sinkpad));
handoff (self);
gst_pad_push (self->_priv->srcpad, buf);
if (self->_priv->sleep_time)
usleep (self->_priv->sleep_time);
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
}*/
}
%{
GstPluginDesc plugin_desc = {
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"identity2",
gst_identity2_plugin_init
};
%}
noinst_PROGRAMS = player
player_SOURCES = player.c
player_CFLAGS = $(GST_CFLAGS) $(GCONF_CFLAGS)
player_LDFLAGS = \
$(GST_LIBS) \
$(top_builddir)/gst-libs/gst/gconf/libgstgconf-@GST_MAJORMINOR@.la \
$(top_builddir)/gst-libs/gst/play/libgstplay-@GST_MAJORMINOR@.la \
$(top_builddir)/gst-libs/gst/libgstinterfaces-$(GST_MAJORMINOR).la
<
/* GStreamer
* Copyright (C) 2003 Julien Moutte <julien@moutte.net>
*
* 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/play/play.h>
#include <gst/gconf/gconf.h>
static GMainLoop *loop = NULL;
static gint64 length = 0;
static void
print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
{
gint i, count;
count = gst_tag_list_get_tag_size (list, tag);
for (i = 0; i < count; i++) {
gchar *str;
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
if (!gst_tag_list_get_string_index (list, tag, i, &str))
g_assert_not_reached ();
} else {
str =
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
}
if (i == 0) {
g_print ("%15s: %s\n", gst_tag_get_nick (tag), str);
} else {
g_print (" : %s\n", str);
}
g_free (str);
}
}
static void
got_found_tag (GstPlay * play, GstElement * source, GstTagList * tag_list)
{
gst_tag_list_foreach (tag_list, print_tag, NULL);
}
static void
got_time_tick (GstPlay * play, gint64 time_nanos)
{
g_print ("time tick %f\n", time_nanos / (float) GST_SECOND);
}
static void
got_stream_length (GstPlay * play, gint64 length_nanos)
{
g_print ("got length %" G_GUINT64_FORMAT "\n", length_nanos);
length = length_nanos;
}
static void
got_video_size (GstPlay * play, gint width, gint height)
{
g_print ("got video size %d, %d\n", width, height);
}
static void
got_eos (GstPlay * play)
{
g_print ("End Of Stream\n");
g_main_loop_quit (loop);
}
static gboolean
seek_timer (GstPlay * play)
{
gst_play_seek_to_time (play, length / 2);
return FALSE;
}
int
main (int argc, char *argv[])
{
GstPlay *play;
GstElement *data_src, *video_sink, *audio_sink, *vis_element;
GError *error = NULL;
/* Initing GStreamer library */
gst_init (&argc, &argv);
if (argc != 2) {
g_print ("usage: %s <video filename>\n", argv[0]);
exit (-1);
}
loop = g_main_loop_new (NULL, FALSE);
/* Creating the GstPlay object */
play = gst_play_new (&error);
if (error) {
g_print ("Error: could not create play object:\n%s\n", error->message);
g_error_free (error);
return 1;
}
/* Getting default audio and video plugins from GConf */
vis_element = gst_element_factory_make ("goom", "vis_element");
data_src = gst_element_factory_make ("gnomevfssrc", "source");
audio_sink = gst_gconf_get_default_audio_sink ();
if (!GST_IS_ELEMENT (audio_sink))
g_error ("Could not get default audio sink from GConf");
video_sink = gst_gconf_get_default_video_sink ();
if (!GST_IS_ELEMENT (video_sink))
g_error ("Could not get default video sink from GConf");
/* Let's send them to GstPlay object */
if (!gst_play_set_audio_sink (play, audio_sink))
g_warning ("Could not set audio sink");
if (!gst_play_set_video_sink (play, video_sink))
g_warning ("Could not set video sink");
if (!gst_play_set_data_src (play, data_src))
g_warning ("Could not set data src");
if (!gst_play_set_visualization (play, vis_element))
g_warning ("Could not set visualisation");
/* Setting location we want to play */
if (!gst_play_set_location (play, argv[1]))
g_warning ("Could not set location");
/* Uncomment that line to get an XML dump of the pipeline */
/* gst_xml_write_file (GST_ELEMENT (play), stdout); */