gstreamer/tests/old/testsuite/pad/link.c
Ronald S. Bultje d8d03b6b98 docs/pwg/advanced-types.xml: Fix description for buffer-frames=0.
Original commit message from CVS:
* docs/pwg/advanced-types.xml:
Fix description for buffer-frames=0.
* docs/gst/tmpl/gstbin.sgml:
* gst/gstbin.c: (gst_bin_child_state_change_func),
(gst_bin_change_state), (gst_bin_change_state_norecurse):
* gst/gstbin.h:
* testsuite/threads/Makefile.am:
* testsuite/threads/threadi.c: (cb_timeout), (cb_quit), (cb_eos),
(cb_state), (cb_play), (main):
Fix non-recursive state changes to *really* change the state
of the object, and not just call parent_class->state_change.
Fix a lot of lockups caused by this. Fixes #132775. Add test
for the problem. Also enable test to show #142588 (fixed).
* gst/gstthread.c: (gst_thread_change_state),
(gst_thread_child_state_change):
Don't exit the thread if we go to NULL and are inside thread
context. Instead, return control to the main thread context
and exit from there.
* gst/gstelement.c: (gst_element_disable_threadsafe_properties):
Don't unset virtual functions, since those may still be used.
That's not necessarily correct, but suffices for now.
* configure.ac:
* testsuite/Makefile.am:
* testsuite/pad/Makefile.am:
* testsuite/pad/chainnopull.c: (gst_test_sink_class_init),
(gst_test_sink_base_init), (gst_test_sink_chain),
(gst_test_sink_init), (main):
* testsuite/pad/getnopush.c: (gst_test_src_class_init),
(gst_test_src_base_init), (gst_test_src_get), (gst_test_src_init),
(main):
* testsuite/pad/link.c: (gst_test_element_class_init),
(gst_test_element_base_init), (gst_test_src_get),
(gst_test_src_loop), (gst_test_src_init), (gst_test_filter_chain),
(gst_test_filter_loop), (gst_test_filter_init),
(gst_test_sink_chain), (gst_test_sink_loop), (gst_test_sink_init),
(cb_error), (main):
Add tests to show #150546. Pass, but should fail (currently
disabled from the testsuite).
* gst/gstscheduler.c: (gst_scheduler_dispose):
Dereference child schedulers on dispose (#94464).
* testsuite/bytestream/filepadsink.c: (gst_fp_sink_init):
Fix typo.
* testsuite/threads/thread.c: (main):
Add more debug.
2005-01-31 15:51:19 +00:00

194 lines
4.9 KiB
C

/*
* Test that:
* - get-based sources can return data, loop-based sources can push.
* - chain-based filters receive/push, loop-based filters can pull/push.
* - chain-based sinks receive, loop-based sinks pull.
*/
#include <gst/gst.h>
/*
* Scary type code.
*/
typedef struct _GstTestElement
{
GstElement parent;
GstPad *srcpad, *sinkpad;
} GstTestSrc, GstTestFilter, GstTestSink, GstTestElement;
typedef GstElementClass GstTestSrcClass, GstTestFilterClass, GstTestSinkClass,
GstTestElementClass;
#define gst_test_src_class_init gst_test_element_class_init
#define gst_test_filter_class_init gst_test_element_class_init
#define gst_test_sink_class_init gst_test_element_class_init
#define gst_test_src_base_init gst_test_element_base_init
#define gst_test_filter_base_init gst_test_element_base_init
#define gst_test_sink_base_init gst_test_element_base_init
static void
gst_test_element_class_init (GstTestElementClass * klass)
{
}
static void
gst_test_element_base_init (gpointer klass)
{
}
/*
* Actual element code.
*/
gboolean loop = FALSE;
static GstData *
gst_test_src_get (GstPad * pad)
{
return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT));
}
static void
gst_test_src_loop (GstElement * element)
{
GstTestSrc *src = (GstTestElement *) element;
gst_pad_push (src->srcpad, gst_test_src_get (src->srcpad));
}
static void
gst_test_src_init (GstTestElement * src)
{
src->srcpad = gst_pad_new ("src", GST_PAD_SRC);
if (loop) {
gst_element_set_loop_function (GST_ELEMENT (src), gst_test_src_loop);
} else {
gst_pad_set_get_function (src->srcpad, gst_test_src_get);
}
gst_element_add_pad (GST_ELEMENT (src), src->srcpad);
GST_FLAG_SET (src, GST_ELEMENT_EVENT_AWARE);
}
static void
gst_test_filter_chain (GstPad * pad, GstData * data)
{
GstTestFilter *filter = (GstTestElement *) gst_pad_get_parent (pad);
gst_pad_push (filter->srcpad, data);
}
static void
gst_test_filter_loop (GstElement * element)
{
GstTestFilter *filter = (GstTestElement *) element;
gst_test_filter_chain (filter->sinkpad, gst_pad_pull (filter->sinkpad));
}
static void
gst_test_filter_init (GstTestElement * filter)
{
filter->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
if (loop) {
gst_element_set_loop_function (GST_ELEMENT (filter), gst_test_filter_loop);
} else {
gst_pad_set_chain_function (filter->sinkpad, gst_test_filter_chain);
}
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
filter->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
GST_FLAG_SET (filter, GST_ELEMENT_EVENT_AWARE);
}
static void
gst_test_sink_chain (GstPad * pad, GstData * data)
{
gst_data_unref (data);
}
static void
gst_test_sink_loop (GstElement * element)
{
GstTestSink *sink = (GstTestElement *) element;
gst_test_sink_chain (sink->sinkpad, gst_pad_pull (sink->sinkpad));
}
static void
gst_test_sink_init (GstTestElement * sink)
{
sink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
if (loop) {
gst_element_set_loop_function (GST_ELEMENT (sink), gst_test_sink_loop);
} else {
gst_pad_set_chain_function (sink->sinkpad, gst_test_sink_chain);
}
gst_element_add_pad (GST_ELEMENT (sink), sink->sinkpad);
GST_FLAG_SET (sink, GST_ELEMENT_EVENT_AWARE);
}
#define parent_class src_parent_class
GST_BOILERPLATE (GstTestSrc, gst_test_src, GstElement, GST_TYPE_ELEMENT);
#undef parent_class
#define parent_class filter_parent_class
GST_BOILERPLATE (GstTestFilter, gst_test_filter, GstElement, GST_TYPE_ELEMENT);
#undef parent_class
#define parent_class sink_parent_class
GST_BOILERPLATE (GstTestSink, gst_test_sink, GstElement, GST_TYPE_ELEMENT);
#undef parent_class
/*
* Actual test.
*/
static void
cb_error (GstElement * element)
{
g_assert_not_reached ();
}
int
main (int argc, char *argv[])
{
GstElement *pipeline, *src, *filter, *sink;
gint n, r;
gboolean res;
gst_init (&argc, &argv);
for (r = 0; r < 2; r++) {
pipeline = gst_pipeline_new ("p");
g_signal_connect (pipeline, "error", G_CALLBACK (cb_error), NULL);
src = g_object_new (gst_test_src_get_type (), NULL);
gst_object_set_name (GST_OBJECT (src), "src");
filter = g_object_new (gst_test_filter_get_type (), NULL);
gst_object_set_name (GST_OBJECT (filter), "filter");
sink = g_object_new (gst_test_sink_get_type (), NULL);
gst_object_set_name (GST_OBJECT (sink), "sink");
gst_bin_add_many (GST_BIN (pipeline), src, filter, sink, NULL);
res = gst_element_link (src, filter);
g_assert (res);
res = gst_element_link (filter, sink);
g_assert (res);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
for (n = 0; n < 100; n++) {
if (!gst_bin_iterate (GST_BIN (pipeline)))
g_assert_not_reached ();
}
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
/* switch element types */
g_print ("Loop=%s done\n", loop ? "true" : "false");
loop = !loop;
}
return 0;
}