7041c909833593a74e7c56e1aed39224dfee29e5
[platform/upstream/gstreamer.git] / tests / old / testsuite / pad / getnopush.c
1 /*
2  * this tests that get-based pads don't push.
3  */
4
5 #include <gst/gst.h>
6
7 typedef struct _GstTestSrc
8 {
9   GstElement parent;
10   GstPad *srcpad;
11 } GstTestSrc;
12
13 typedef GstElementClass GstTestSrcClass;
14
15 static void
16 gst_test_src_class_init (GstTestSrcClass * klass)
17 {
18 }
19 static void
20 gst_test_src_base_init (gpointer klass)
21 {
22 }
23
24 static GstData *
25 gst_test_src_get (GstPad * pad)
26 {
27   GstEvent *event;
28
29   event = gst_event_new (GST_EVENT_INTERRUPT);
30   gst_event_ref (event);
31   gst_pad_push (pad, GST_DATA (event));
32
33   return GST_DATA (event);
34 }
35
36 static void
37 gst_test_src_init (GstTestSrc * src)
38 {
39   src->srcpad = gst_pad_new ("src", GST_PAD_SRC);
40   gst_pad_set_get_function (src->srcpad, gst_test_src_get);
41   gst_element_add_pad (GST_ELEMENT (src), src->srcpad);
42 }
43
44 GST_BOILERPLATE (GstTestSrc, gst_test_src, GstElement, GST_TYPE_ELEMENT);
45
46 int
47 main (int argc, char *argv[])
48 {
49   GstElement *pipeline, *testsrc, *fakesink;
50   gint n;
51
52   gst_init (&argc, &argv);
53
54   pipeline = gst_pipeline_new ("p");
55   testsrc = g_object_new (gst_test_src_get_type (), NULL);
56   gst_object_set_name (GST_OBJECT (testsrc), "src");
57   fakesink = gst_element_factory_make ("fakesink", "sink");
58   gst_bin_add_many (GST_BIN (pipeline), testsrc, fakesink, NULL);
59   gst_element_link (testsrc, fakesink);
60   gst_element_set_state (pipeline, GST_STATE_PLAYING);
61
62   for (n = 0; n < 100; n++) {
63     if (!gst_bin_iterate (GST_BIN (pipeline)))
64       break;
65   }
66
67   gst_element_set_state (pipeline, GST_STATE_NULL);
68   gst_object_unref (GST_OBJECT (pipeline));
69
70   return 0;
71 }