2003-02-27 21:07:31 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
static GstElement *src1, *src2, *sink, *pipeline, *bin;
|
|
|
|
static gint state = 0;
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
notify (GstProbe * probe, GstData ** data, gpointer user_data)
|
2003-02-27 21:07:31 +00:00
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case 0:
|
|
|
|
if (GST_BUFFER_TIMESTAMP (*data) == 10) {
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
|
2003-02-27 21:07:31 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_element_unlink_pads (GST_ELEMENT (src1), "src", sink, "sink");
|
|
|
|
gst_bin_add (GST_BIN (bin), src2);
|
|
|
|
gst_bin_remove (GST_BIN (bin), src1);
|
|
|
|
gst_element_link_pads (GST_ELEMENT (src2), "src", sink, "sink");
|
|
|
|
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
|
|
|
|
state++;
|
|
|
|
gst_data_unref (*data);
|
|
|
|
return FALSE;
|
2003-02-27 21:07:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
GST_BUFFER_TIMESTAMP (*data) = GST_BUFFER_TIMESTAMP (*data) + 10;
|
|
|
|
if (GST_BUFFER_TIMESTAMP (*data) == 20) {
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_data_unref (*data);
|
|
|
|
*data = GST_DATA (gst_event_new (GST_EVENT_EOS));
|
|
|
|
gst_element_set_state (src2, GST_STATE_PAUSED);
|
|
|
|
return TRUE;
|
2003-02-27 21:07:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2004-03-13 15:27:01 +00:00
|
|
|
main (int argc, gchar * argv[])
|
2003-02-27 21:07:31 +00:00
|
|
|
{
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("main_pipeline");
|
|
|
|
bin = gst_bin_new ("control");
|
|
|
|
|
|
|
|
src1 = gst_element_factory_make ("fakesrc", "src1");
|
|
|
|
src2 = gst_element_factory_make ("fakesrc", "src2");
|
|
|
|
|
|
|
|
gst_bin_add (GST_BIN (bin), src1);
|
|
|
|
|
|
|
|
sink = gst_element_factory_make ("fakesink", "sink");
|
|
|
|
gst_bin_add (GST_BIN (pipeline), sink);
|
|
|
|
gst_bin_add (GST_BIN (pipeline), bin);
|
|
|
|
|
|
|
|
gst_element_link_pads (GST_ELEMENT (src1), "src", sink, "sink");
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_connect (pipeline, "deep_notify",
|
|
|
|
G_CALLBACK (gst_element_default_deep_notify), NULL);
|
|
|
|
g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gst_pad_add_probe (gst_element_get_pad (src1, "src"),
|
|
|
|
gst_probe_new (FALSE, notify, NULL));
|
|
|
|
|
|
|
|
gst_pad_add_probe (gst_element_get_pad (src2, "src"),
|
|
|
|
gst_probe_new (FALSE, notify, NULL));
|
2003-02-27 21:07:31 +00:00
|
|
|
|
|
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
|
|
|
|
|
|
|
while (gst_bin_iterate (GST_BIN (pipeline)));
|
|
|
|
|
|
|
|
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
|
|
|
|
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (pipeline);
|
2003-02-27 21:07:31 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|