399bff2039da9d729a3596af5ce56855c4383fd8
[platform/upstream/gstreamer.git] / tests / old / testsuite / schedulers / 143777-2.c
1
2 #include <gst/gst.h>
3
4 int
5 main (int argc, char **argv)
6 {
7   GstElement *src, *sink, *enc, *tee;
8   GstElement *pipeline;
9   int i;
10
11
12   gst_init (&argc, &argv);
13   pipeline = gst_element_factory_make ("pipeline", "pipeline");
14
15   src = gst_element_factory_make ("fakesrc", "src");
16   g_assert (src);
17   tee = gst_element_factory_make ("tee", "tee1");
18   g_assert (tee);
19   enc = gst_element_factory_make ("identity", "enc");
20   g_assert (enc);
21   sink = gst_element_factory_make ("fakesink", "sink");
22   g_assert (sink);
23
24   gst_bin_add_many (GST_BIN (pipeline), src, tee, enc, sink, NULL);
25   if (!gst_element_link_many (src, tee, enc, sink, NULL))
26     g_assert_not_reached ();
27   if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
28     g_assert_not_reached ();
29
30   for (i = 0; i < 5; i++) {
31     if (!gst_bin_iterate (GST_BIN (pipeline)))
32       g_assert_not_reached ();
33     g_print ("%d\n", i);
34   }
35
36   if (gst_element_set_state (pipeline, GST_STATE_PAUSED) != GST_STATE_SUCCESS)
37     g_assert_not_reached ();
38   gst_element_unlink_many (tee, enc, sink, NULL);
39   gst_bin_remove_many (GST_BIN (pipeline), enc, sink, NULL);
40
41   enc = gst_element_factory_make ("identity", "enc");
42   g_assert (enc);
43   sink = gst_element_factory_make ("fakesink", "sink");
44   g_assert (sink);
45   gst_bin_add_many (GST_BIN (pipeline), enc, sink, NULL);
46   if (!gst_element_link_many (tee, enc, sink, NULL))
47     g_assert_not_reached ();
48   if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
49     g_assert_not_reached ();
50
51   for (i = 5; i < 10; i++) {
52     if (!gst_bin_iterate (GST_BIN (pipeline)))
53       g_assert_not_reached ();
54     g_print ("%d\n", i);
55   }
56   g_print ("cleaning up...\n");
57   gst_object_unref (GST_OBJECT (pipeline));
58
59   g_print ("done.\n");
60   return 0;
61 }