6776e49a65a0d248d06d479b291ae2b822760280
[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 main(int argc,char *argv[]) 
9 {
10   GstElement *fakesrc, *fakesink;
11   GstElement *thread, *thread2;
12   GstElement *queue;
13   gint x;
14
15   gst_init(&argc,&argv);
16
17   thread = gst_thread_new("thread");
18   g_assert(thread != NULL);
19
20   thread2 = gst_thread_new("thread");
21   g_assert(thread2 != NULL);
22
23   queue = gst_element_factory_make("queue", "the_queue");
24   g_assert(queue != NULL);
25
26
27   fakesrc = gst_element_factory_make("fakesrc", "fake_source");
28   g_assert(fakesrc != NULL);
29
30   fakesink = gst_element_factory_make("fakesink", "fake_sink");
31   g_assert(fakesink != NULL);
32
33   gst_bin_add_many (GST_BIN(thread), thread2, queue, fakesink, NULL);
34
35   gst_bin_add(GST_BIN(thread2), fakesrc);
36   gst_element_add_ghost_pad (thread2, gst_element_get_pad (fakesrc, "src"), "src");
37   gst_element_link_many (thread2, queue, fakesink, NULL);
38
39   for (x = 0 ; x < 10 ; x++){
40     g_print("playing %d\n", x);
41     gst_element_set_state(thread, GST_STATE_PLAYING);
42     g_usleep (G_USEC_PER_SEC);
43
44     g_print("nulling %d\n", x);
45     gst_element_set_state(thread, GST_STATE_NULL);
46     g_usleep (G_USEC_PER_SEC);
47   }
48
49   exit(0);
50 }