mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-12 12:21:30 +00:00
a98aef82db
Original commit message from CVS: * check/gst/gstbin.c: (GST_START_TEST): * docs/gst/gstreamer-sections.txt: * gst/base/gstbasesink.c: (gst_base_sink_init): * gst/base/gstbasesrc.c: (gst_base_src_init), (gst_base_src_get_range), (gst_base_src_check_get_range), (gst_base_src_start), (gst_base_src_stop): * gst/base/gstbasesrc.h: * gst/elements/gstfakesrc.c: (gst_fake_src_set_property): * gst/gstbin.c: (gst_bin_add_func), (gst_bin_remove_func), (bin_element_is_sink), (reset_degree), (gst_bin_element_set_state), (bin_bus_handler): * gst/gstbin.h: * gst/gstbuffer.h: * gst/gstbus.c: (gst_bus_post), (gst_bus_set_flushing): * gst/gstbus.h: * gst/gstelement.c: (gst_element_is_locked_state), (gst_element_set_locked_state), (gst_element_commit_state), (gst_element_set_state): * gst/gstelement.h: * gst/gstindex.c: (gst_index_init): * gst/gstindex.h: * gst/gstminiobject.h: * gst/gstobject.c: (gst_object_init), (gst_object_sink), (gst_object_set_parent): * gst/gstobject.h: * gst/gstpad.c: (gst_pad_set_blocked_async), (gst_pad_is_blocked), (gst_pad_get_caps_unlocked), (gst_pad_set_caps): * gst/gstpad.h: * gst/gstpadtemplate.h: * gst/gstpipeline.c: (gst_pipeline_provide_clock_func), (gst_pipeline_use_clock), (gst_pipeline_auto_clock): * gst/gstpipeline.h: * gst/indexers/gstfileindex.c: (gst_file_index_load), (gst_file_index_commit): * testsuite/bytestream/filepadsink.c: (gst_fp_sink_init): * testsuite/pad/link.c: (gst_test_src_init), (gst_test_filter_init), (gst_test_sink_init): * testsuite/states/locked.c: (main): renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
194 lines
4.9 KiB
C
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_OBJECT_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_OBJECT_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_OBJECT_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 (pipeline);
|
|
|
|
/* switch element types */
|
|
g_print ("Loop=%s done\n", loop ? "true" : "false");
|
|
loop = !loop;
|
|
}
|
|
|
|
return 0;
|
|
}
|