2001-11-25 06:30:34 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
int main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
GstElement *osssink, *pipe1, *pipe2, *bin, *filesrc, *mad, *fakesink;
|
|
|
|
|
|
|
|
gst_init(&argc, &argv);
|
|
|
|
|
|
|
|
if (argc!=2) {
|
|
|
|
g_print("usage: %s file.mp3\n", argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
filesrc = gst_elementfactory_make("filesrc", "filesrc");
|
|
|
|
mad = gst_elementfactory_make("mad", "mad");
|
|
|
|
bin = gst_bin_new("bin");
|
|
|
|
pipe1 = gst_pipeline_new("pipe1");
|
|
|
|
pipe2 = gst_pipeline_new("pipe2");
|
|
|
|
osssink = gst_elementfactory_make("osssink", "osssink");
|
|
|
|
fakesink = gst_elementfactory_make("fakesink", "fakesink");
|
|
|
|
|
|
|
|
g_object_set(G_OBJECT(filesrc), "location", argv[1], NULL);
|
|
|
|
|
2001-11-26 01:48:19 +00:00
|
|
|
// make the first pipeline
|
2001-11-25 06:30:34 +00:00
|
|
|
gst_bin_add (GST_BIN(pipe1), filesrc);
|
|
|
|
gst_bin_add (GST_BIN(pipe1), fakesink);
|
|
|
|
gst_element_connect(filesrc, "src", fakesink, "sink");
|
|
|
|
|
2001-11-26 01:48:19 +00:00
|
|
|
// initialize cothreads
|
2001-11-25 06:30:34 +00:00
|
|
|
gst_element_set_state(pipe1, GST_STATE_PLAYING);
|
|
|
|
gst_element_set_state(pipe1, GST_STATE_READY);
|
|
|
|
|
2001-11-26 01:48:19 +00:00
|
|
|
// destroy the fakesink, but keep filesrc (its state is GST_STATE_READY)
|
2001-11-25 06:30:34 +00:00
|
|
|
gst_element_disconnect(filesrc, "src", fakesink, "sink");
|
|
|
|
gst_object_ref(GST_OBJECT(filesrc));
|
|
|
|
gst_bin_remove(GST_BIN(pipe1), filesrc);
|
|
|
|
gst_bin_remove(GST_BIN(pipe1), fakesink);
|
|
|
|
|
2001-11-26 01:48:19 +00:00
|
|
|
// make a new pipeline
|
2001-11-25 06:30:34 +00:00
|
|
|
gst_bin_add (GST_BIN(pipe2), mad);
|
|
|
|
gst_bin_add (GST_BIN(pipe2), osssink);
|
|
|
|
gst_element_connect(mad, "src", osssink, "sink");
|
|
|
|
|
2001-11-26 01:48:19 +00:00
|
|
|
// change the new pipeline's state to READY (is this necessary?)
|
|
|
|
gst_element_set_state(pipe2, GST_STATE_READY);
|
|
|
|
gst_bin_add (GST_BIN(pipe2), filesrc);
|
|
|
|
gst_element_connect(filesrc, "src", mad, "sink");
|
|
|
|
|
|
|
|
// show the pipeline state
|
2001-11-25 06:30:34 +00:00
|
|
|
xmlDocDump(stdout, gst_xml_write(pipe2));
|
|
|
|
|
2001-11-26 01:48:19 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|