4 * this tests if we can make a GstBin and iterate it inside a GThread
7 #define MAX_IDENTITIES 29
8 #define RUNS_PER_IDENTITY 5
10 gboolean running = FALSE;
11 gboolean done = FALSE;
14 construct_pipeline (GstElement *pipeline, gint identities)
16 GstElement *src, *sink, *identity = NULL;
20 src = gst_element_factory_make ("fakesrc", NULL);
21 sink = gst_element_factory_make ("fakesink", NULL);
24 gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
27 for (i = 0; i < identities; ++i)
29 identity = gst_element_factory_make ("identity", NULL);
31 gst_bin_add (GST_BIN (pipeline), identity);
32 gst_element_link (from, identity);
35 gst_element_link (identity, sink);
37 g_object_set (G_OBJECT (src), "num_buffers", 10, "sizetype", 3, NULL);
41 iterator (GstElement *bin)
43 gst_element_set_state (bin, GST_STATE_PLAYING);
44 while (gst_bin_iterate (GST_BIN (bin))) g_print ("+");
45 gst_element_set_state (bin, GST_STATE_NULL);
51 main (gint argc, gchar *argv[])
53 int runs = MAX_IDENTITIES * RUNS_PER_IDENTITY;
58 gst_init (&argc, &argv);
60 for (i = 0; i < runs; ++i)
62 pipeline = gst_pipeline_new ("main_pipeline");
65 /* connect state change signal */
66 construct_pipeline (pipeline, i / RUNS_PER_IDENTITY + 1);
69 g_thread_create ((GThreadFunc) iterator, pipeline, FALSE, NULL);
70 g_print ("Created GThread\n");
72 g_print ("Waiting for thread PLAYING->PAUSED\n");
73 while (!done) /* do nothing */;
75 g_print ("Unreffing pipeline\n");
76 g_object_unref (G_OBJECT (pipeline));