f96f90ba15dc74abc17822e81c5d24b4b720fffc
[platform/upstream/gstreamer.git] / tests / threadstate / threadstate4.c
1 #include <stdlib.h>
2 #include <gst/gst.h>
3
4 /* this pipeline is:
5  * { { fakesrc } ! queue ! fakesink }
6  */
7
8 int
9 main (int argc, char *argv[])
10 {
11   GstElement *fakesrc, *fakesink;
12   GstElement *thread, *thread2;
13   GstElement *queue;
14   gint x;
15
16   gst_init (&argc, &argv);
17
18   thread = gst_thread_new ("thread");
19   g_assert (thread != NULL);
20
21   thread2 = gst_thread_new ("thread");
22   g_assert (thread2 != NULL);
23
24   queue = gst_element_factory_make ("queue", "the_queue");
25   g_assert (queue != NULL);
26
27
28   fakesrc = gst_element_factory_make ("fakesrc", "fake_source");
29   g_assert (fakesrc != NULL);
30
31   fakesink = gst_element_factory_make ("fakesink", "fake_sink");
32   g_assert (fakesink != NULL);
33
34   gst_bin_add_many (GST_BIN (thread), thread2, queue, fakesink, NULL);
35
36   gst_bin_add (GST_BIN (thread2), fakesrc);
37   gst_element_add_ghost_pad (thread2, gst_element_get_pad (fakesrc, "src"),
38       "src");
39   gst_element_link_many (thread2, queue, fakesink, NULL);
40
41   for (x = 0; x < 10; x++) {
42     g_print ("playing %d\n", x);
43     gst_element_set_state (thread, GST_STATE_PLAYING);
44     g_usleep (G_USEC_PER_SEC);
45
46     g_print ("nulling %d\n", x);
47     gst_element_set_state (thread, GST_STATE_NULL);
48     g_usleep (G_USEC_PER_SEC);
49   }
50
51   exit (0);
52 }