2003-03-25 19:41:23 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
#include "unistd.h"
|
|
|
|
|
2003-03-25 19:41:23 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
static GMainLoop *loop;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
|
|
|
|
{
|
|
|
|
g_print ("message %p\n", message);
|
|
|
|
|
|
|
|
if (message->type == GST_MESSAGE_EOS) {
|
|
|
|
g_print ("EOS!!\n");
|
|
|
|
if (g_main_loop_is_running (loop))
|
|
|
|
g_main_loop_quit (loop);
|
|
|
|
}
|
|
|
|
gst_message_unref (message);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-03-25 19:41:23 +00:00
|
|
|
gint
|
2004-03-13 15:27:01 +00:00
|
|
|
main (gint argc, gchar * argv[])
|
2003-03-25 19:41:23 +00:00
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
2004-03-13 15:27:01 +00:00
|
|
|
GstElement *fakesrc1, *fakesink1;
|
|
|
|
GstElement *fakesrc2, *fakesink2;
|
2005-03-21 17:34:02 +00:00
|
|
|
GstBus *bus;
|
2003-03-25 19:41:23 +00:00
|
|
|
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("pipeline");
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
bus = gst_element_get_bus (pipeline);
|
2005-09-23 11:41:30 +00:00
|
|
|
gst_bus_add_watch (bus, GST_MESSAGE_EOS, (GstBusFunc) message_received,
|
|
|
|
(gpointer) pipeline);
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (bus);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
2003-03-25 19:41:23 +00:00
|
|
|
fakesrc1 = gst_element_factory_make ("fakesrc", "fakesrc1");
|
|
|
|
g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
|
|
|
|
fakesink1 = gst_element_factory_make ("fakesink", "fakesink1");
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_bin_add (GST_BIN (pipeline), fakesrc1);
|
|
|
|
gst_bin_add (GST_BIN (pipeline), fakesink1);
|
|
|
|
gst_pad_link (gst_element_get_pad (fakesrc1, "src"),
|
|
|
|
gst_element_get_pad (fakesink1, "sink"));
|
2003-03-25 19:41:23 +00:00
|
|
|
|
|
|
|
fakesrc2 = gst_element_factory_make ("fakesrc", "fakesrc2");
|
|
|
|
g_object_set (G_OBJECT (fakesrc2), "num_buffers", 5, NULL);
|
|
|
|
fakesink2 = gst_element_factory_make ("fakesink", "fakesink2");
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_bin_add (GST_BIN (pipeline), fakesrc2);
|
|
|
|
gst_bin_add (GST_BIN (pipeline), fakesink2);
|
|
|
|
gst_pad_link (gst_element_get_pad (fakesrc2, "src"),
|
|
|
|
gst_element_get_pad (fakesink2, "sink"));
|
2003-03-25 19:41:23 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
|
2005-03-21 17:34:02 +00:00
|
|
|
G_CALLBACK (gst_object_default_deep_notify), NULL);
|
2003-03-25 19:41:23 +00:00
|
|
|
|
|
|
|
GST_FLAG_SET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
|
|
|
|
GST_FLAG_SET (fakesink2, GST_ELEMENT_LOCKED_STATE);
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
g_print ("play..\n");
|
2003-03-25 19:41:23 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
g_main_loop_run (loop);
|
2003-03-25 19:41:23 +00:00
|
|
|
|
|
|
|
g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_READY);
|
|
|
|
|
2003-03-25 19:41:23 +00:00
|
|
|
GST_FLAG_UNSET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
|
|
|
|
GST_FLAG_UNSET (fakesink2, GST_ELEMENT_LOCKED_STATE);
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
g_print ("play..\n");
|
2003-03-25 19:41:23 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
g_main_loop_run (loop);
|
|
|
|
|
2003-03-25 19:41:23 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
|
2005-06-28 09:59:01 +00:00
|
|
|
gst_object_unref (pipeline);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-03-25 19:41:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|