2 * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU 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 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 static gboolean empty;
25 static gboolean handoff;
26 static GstElement *pipeline2;
29 queue_empty (GstElement * element)
31 g_print ("queue empty\n");
37 queue_filled (GstElement * element)
39 g_print ("queue filled\n");
42 /* read from the other end */
48 g_print ("emptying queue with 5 second timeout...\n");
49 while (!bug && !handoff) {
50 gst_bin_iterate (GST_BIN (pipeline2));
55 handoff_identity (GstElement * element)
57 g_print ("identity handoff\n");
62 main (gint argc, gchar ** argv)
64 GstElement *pipeline, *src, *sink, *queue, *id;
66 gst_init (&argc, &argv);
68 g_print ("setting up...\n");
70 pipeline = gst_element_factory_make ("pipeline", NULL);
72 src = gst_element_factory_make ("fakesrc", NULL);
74 queue = gst_element_factory_make ("queue", NULL);
76 g_signal_connect (G_OBJECT (queue), "overrun", (GCallback) queue_filled,
78 g_signal_connect (G_OBJECT (queue), "underrun", (GCallback) queue_empty,
80 gst_bin_add_many (GST_BIN (pipeline), src, queue, NULL);
82 gst_element_link_pads (src, "src", queue, "sink");
84 /* second pipeline for sinks */
85 pipeline2 = gst_element_factory_make ("pipeline", NULL);
87 id = gst_element_factory_make ("identity", NULL);
89 g_signal_connect (G_OBJECT (id), "handoff", (GCallback) handoff_identity,
92 sink = gst_element_factory_make ("fakesink", NULL);
94 gst_bin_add_many (GST_BIN (pipeline2), id, sink, NULL);
96 gst_element_link_pads (queue, "src", id, "sink");
97 gst_element_link_pads (id, "src", sink, "sink");
99 if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
100 g_assert_not_reached ();
102 if (gst_element_set_state (pipeline2, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
103 g_assert_not_reached ();
105 g_print ("running...\n");
109 gst_bin_iterate (GST_BIN (pipeline));
113 g_print ("relinking...\n");
114 /* now unlink and link id and sink */
115 gst_element_unlink_pads (id, "src", sink, "sink");
116 gst_element_link_pads (id, "src", sink, "sink");
118 g_print ("running again...\n");
122 gst_bin_iterate (GST_BIN (pipeline));
126 /* trigger the bug */
129 g_print ("cleaning up...\n");
130 gst_object_unref (pipeline);
131 gst_object_unref (pipeline2);
132 src = id = sink = pipeline = pipeline2 = NULL;