2001-11-25 06:30:34 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2002-01-19 06:29:40 +00:00
|
|
|
/* This test will fail because it tries to allocate two cothread_context's in
|
|
|
|
* one thread. This will cause a segfault. This is a problem with gstreamer's
|
|
|
|
* cothreading that will be fixed in the future.
|
|
|
|
*/
|
|
|
|
|
2001-11-25 06:30:34 +00:00
|
|
|
int main (int argc, char *argv[])
|
|
|
|
{
|
2001-11-26 01:55:36 +00:00
|
|
|
GstElement *fakesrc, *fakesink1, *fakesink2, *pipe1, *pipe2;
|
2001-11-25 06:30:34 +00:00
|
|
|
|
|
|
|
gst_init(&argc, &argv);
|
|
|
|
|
2001-11-26 01:55:36 +00:00
|
|
|
if (argc!=1) {
|
|
|
|
g_print("usage: %s\n", argv[0]);
|
2001-11-25 06:30:34 +00:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
fakesrc = gst_element_factory_make("fakesrc", "fakesrc");
|
|
|
|
fakesink1 = gst_element_factory_make("fakesink", "fakesink1");
|
|
|
|
fakesink2 = gst_element_factory_make("fakesink", "fakesink2");
|
2001-11-25 06:30:34 +00:00
|
|
|
pipe1 = gst_pipeline_new("pipe1");
|
|
|
|
pipe2 = gst_pipeline_new("pipe2");
|
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/* make the first pipeline */
|
2001-11-26 01:55:36 +00:00
|
|
|
gst_bin_add (GST_BIN(pipe1), fakesrc);
|
|
|
|
gst_bin_add (GST_BIN(pipe1), fakesink1);
|
2002-04-07 23:32:16 +00:00
|
|
|
gst_element_connect_pads (fakesrc, "src", fakesink1, "sink");
|
2001-11-25 06:30:34 +00:00
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/* initialize cothreads */
|
2001-11-25 06:30:34 +00:00
|
|
|
gst_element_set_state(pipe1, GST_STATE_PLAYING);
|
2002-01-17 05:04:17 +00:00
|
|
|
gst_bin_iterate (GST_BIN (pipe1));
|
2001-11-25 06:30:34 +00:00
|
|
|
gst_element_set_state(pipe1, GST_STATE_READY);
|
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/* destroy the fakesink, but keep fakesrc (its state is GST_STATE_READY) */
|
2002-04-07 23:32:16 +00:00
|
|
|
gst_element_disconnect_pads (fakesrc, "src", fakesink1, "sink");
|
2001-11-26 01:55:36 +00:00
|
|
|
gst_object_ref(GST_OBJECT(fakesrc));
|
|
|
|
gst_bin_remove(GST_BIN(pipe1), fakesrc);
|
|
|
|
gst_bin_remove(GST_BIN(pipe1), fakesink1);
|
2002-01-19 06:29:40 +00:00
|
|
|
gst_object_unref(GST_OBJECT(pipe1));
|
2001-11-25 06:30:34 +00:00
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/* make a new pipeline */
|
2001-11-26 01:55:36 +00:00
|
|
|
gst_bin_add (GST_BIN(pipe2), fakesink2);
|
2001-11-25 06:30:34 +00:00
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/* don't change the new pipeline's state, it should change on the bin_add */
|
2001-11-26 01:55:36 +00:00
|
|
|
gst_bin_add (GST_BIN(pipe2), fakesrc);
|
2002-04-07 23:32:16 +00:00
|
|
|
gst_element_connect_pads (fakesrc, "src", fakesink2, "sink");
|
2001-11-26 01:48:19 +00:00
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/* show the pipeline state */
|
2002-01-11 15:49:47 +00:00
|
|
|
gst_xml_write_file (GST_ELEMENT (pipe2), stdout);
|
2001-11-25 06:30:34 +00:00
|
|
|
|
2002-03-19 04:10:13 +00:00
|
|
|
/* try to iterate the pipeline */
|
2001-11-25 06:30:34 +00:00
|
|
|
gst_element_set_state(pipe2, GST_STATE_PLAYING);
|
2001-11-26 01:48:19 +00:00
|
|
|
gst_bin_iterate(GST_BIN(pipe2));
|
2001-11-25 06:30:34 +00:00
|
|
|
gst_element_set_state(pipe2, GST_STATE_NULL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|