2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 static GMainLoop *loop;
27 message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
29 g_print ("message %p\n", message);
31 if (message->type == GST_MESSAGE_EOS) {
33 if (g_main_loop_is_running (loop))
34 g_main_loop_quit (loop);
36 gst_message_unref (message);
42 main (gint argc, gchar * argv[])
45 GstElement *fakesrc1, *fakesink1;
46 GstElement *fakesrc2, *fakesink2;
49 gst_init (&argc, &argv);
51 pipeline = gst_pipeline_new ("pipeline");
53 loop = g_main_loop_new (NULL, FALSE);
54 bus = gst_element_get_bus (pipeline);
55 gst_bus_add_watch (bus, (GstBusHandler) message_received, pipeline);
56 gst_object_unref (GST_OBJECT (bus));
58 fakesrc1 = gst_element_factory_make ("fakesrc", "fakesrc1");
59 g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
60 fakesink1 = gst_element_factory_make ("fakesink", "fakesink1");
62 gst_bin_add (GST_BIN (pipeline), fakesrc1);
63 gst_bin_add (GST_BIN (pipeline), fakesink1);
64 gst_pad_link (gst_element_get_pad (fakesrc1, "src"),
65 gst_element_get_pad (fakesink1, "sink"));
67 fakesrc2 = gst_element_factory_make ("fakesrc", "fakesrc2");
68 g_object_set (G_OBJECT (fakesrc2), "num_buffers", 5, NULL);
69 fakesink2 = gst_element_factory_make ("fakesink", "fakesink2");
71 gst_bin_add (GST_BIN (pipeline), fakesrc2);
72 gst_bin_add (GST_BIN (pipeline), fakesink2);
73 gst_pad_link (gst_element_get_pad (fakesrc2, "src"),
74 gst_element_get_pad (fakesink2, "sink"));
76 g_signal_connect (G_OBJECT (pipeline), "deep_notify",
77 G_CALLBACK (gst_object_default_deep_notify), NULL);
79 GST_FLAG_SET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
80 GST_FLAG_SET (fakesink2, GST_ELEMENT_LOCKED_STATE);
83 gst_element_set_state (pipeline, GST_STATE_PLAYING);
85 g_main_loop_run (loop);
87 g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL);
89 gst_element_set_state (pipeline, GST_STATE_READY);
91 GST_FLAG_UNSET (fakesrc2, GST_ELEMENT_LOCKED_STATE);
92 GST_FLAG_UNSET (fakesink2, GST_ELEMENT_LOCKED_STATE);
95 gst_element_set_state (pipeline, GST_STATE_PLAYING);
97 g_main_loop_run (loop);
99 gst_element_set_state (pipeline, GST_STATE_NULL);
101 gst_object_unref (GST_OBJECT (pipeline));