5 * these tests should have a maximum run length, so that they get killed
6 * if they lock up, which they're bound to do.
12 g_print ("compile this test with TESTNUM defined.\n"
13 " available TESTNUMs: \n"
14 " 1: stress test state change \n"
16 " 3: iterate twice \n"
17 " 4: state change while running \n"
18 " 5: state change in thread context\n");
22 construct_pipeline (GstElement *pipeline)
24 GstElement *src, *sink, *queue, *identity, *thread;
26 src = gst_element_factory_make ("fakesrc", NULL);
27 sink = gst_element_factory_make ("fakesink", "sink");
28 identity = gst_element_factory_make ("identity", NULL);
29 queue = gst_element_factory_make ("queue", NULL);
30 thread = gst_element_factory_make ("thread", NULL);
32 gst_element_link_many (src, queue, identity, sink, NULL);
34 gst_bin_add_many (GST_BIN (pipeline), src, queue, thread, NULL);
35 gst_bin_add_many (GST_BIN (thread), identity, sink, NULL);
37 g_object_set (G_OBJECT (src), "num_buffers", 5, NULL);
38 g_object_set (sink, "signal-handoff", TRUE, NULL);
42 change_state (GstElement *element, GstBuffer *buf, GstElement *pipeline)
44 gst_element_set_state (pipeline, GST_STATE_NULL);
48 main (gint argc, gchar *argv[])
52 gst_init (&argc, &argv);
59 pipeline = gst_pipeline_new ("main_pipeline");
60 construct_pipeline (pipeline);
63 g_print ("thread test 1: stress test state changes...\n");
66 gst_element_set_state (pipeline, GST_STATE_NULL);
68 gst_element_set_state (pipeline, GST_STATE_READY);
70 gst_element_set_state (pipeline, GST_STATE_NULL);
72 gst_element_set_state (pipeline, GST_STATE_PAUSED);
74 gst_element_set_state (pipeline, GST_STATE_READY);
76 gst_element_set_state (pipeline, GST_STATE_PAUSED);
77 g_print ("PLAYING\n");
78 gst_element_set_state (pipeline, GST_STATE_PLAYING);
79 /* element likely hits EOS and does a state transition to PAUSED */
81 gst_element_set_state (pipeline, GST_STATE_READY);
83 gst_element_set_state (pipeline, GST_STATE_NULL);
86 if (TESTNUM == 2 || TESTNUM == 3) {
87 gst_element_set_state (pipeline, GST_STATE_PLAYING);
88 g_print ("running ...\n");
89 while (gst_bin_iterate (GST_BIN (pipeline)));
90 gst_element_set_state (pipeline, GST_STATE_NULL);
93 gst_element_set_state (pipeline, GST_STATE_PLAYING);
94 g_print ("running ...\n");
95 while (gst_bin_iterate (GST_BIN (pipeline)));
96 gst_element_set_state (pipeline, GST_STATE_NULL);
101 gst_element_set_state (pipeline, GST_STATE_PLAYING);
102 g_print ("running ...\n");
103 for (run = 0; run < 3; run++) {
104 gst_bin_iterate (GST_BIN (pipeline));
106 gst_element_set_state (pipeline, GST_STATE_NULL);
109 /* I don't this test is supposed to work */
112 sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
115 g_signal_connect (G_OBJECT (sink), "handoff",
116 G_CALLBACK (change_state), pipeline);
117 gst_element_set_state (pipeline, GST_STATE_PLAYING);
118 g_print ("running ...\n");
119 while (gst_bin_iterate (GST_BIN (pipeline)));
120 gst_element_set_state (pipeline, GST_STATE_NULL);