source: trunk/third/gstreamer/testsuite/schedulers/147819.c @ 21005

Revision 21005, 2.9 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21004, which included commits to RCS files with non-trunk default branches.
Line 
1/* GStreamer
2 * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
3 *
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.
8 *
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.
13 *
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.
17 */
18
19#include <unistd.h>
20
21#include <gst/gst.h>
22
23static gboolean handoff;
24
25static void
26handoff_identity1 (GstElement * element)
27{
28  g_print ("identity1 handoff\n");
29  handoff = TRUE;
30}
31
32static void
33handoff_identity2 (GstElement * element)
34{
35  g_print ("identity2 handoff\n");
36  handoff = TRUE;
37}
38
39gint
40main (gint argc, gchar ** argv)
41{
42  GstElement *pipeline, *src, *sink, *id1, *id2;
43
44  gst_init (&argc, &argv);
45
46  g_print ("setting up...\n");
47  /* setup pipeline */
48  pipeline = gst_element_factory_make ("pipeline", NULL);
49  g_assert (pipeline);
50  src = gst_element_factory_make ("fakesrc", NULL);
51  g_assert (src);
52  id1 = gst_element_factory_make ("identity", NULL);
53  g_assert (id1);
54  g_object_set (G_OBJECT (id1), "loop-based", TRUE, NULL);
55  g_object_set (G_OBJECT (id1), "duplicate", 3, NULL);
56  g_signal_connect (G_OBJECT (id1), "handoff", (GCallback) handoff_identity1,
57      NULL);
58
59  id2 = gst_element_factory_make ("identity", NULL);
60  g_assert (id2);
61  g_object_set (G_OBJECT (id2), "loop-based", TRUE, NULL);
62  g_signal_connect (G_OBJECT (id2), "handoff", (GCallback) handoff_identity2,
63      NULL);
64
65  sink = gst_element_factory_make ("fakesink", NULL);
66  g_assert (sink);
67
68  gst_bin_add_many (GST_BIN (pipeline), src, id1, id2, sink, NULL);
69
70  gst_element_link_pads (src, "src", id1, "sink");
71  gst_element_link_pads (id1, "src", id2, "sink");
72  gst_element_link_pads (id2, "src", sink, "sink");
73
74  if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
75    g_assert_not_reached ();
76
77  g_print ("running...\n");
78  gst_bin_iterate (GST_BIN (pipeline));
79  gst_bin_iterate (GST_BIN (pipeline));
80  gst_bin_iterate (GST_BIN (pipeline));
81
82  /* do ugly stuff here */
83  gst_object_ref (GST_OBJECT (id1));
84  gst_bin_remove (GST_BIN (pipeline), id1);
85  gst_element_link_pads (src, "src", id1, "sink");
86  gst_element_link_pads (id1, "src", id2, "sink");
87
88  gst_bin_iterate (GST_BIN (pipeline));
89  gst_bin_iterate (GST_BIN (pipeline));
90  gst_bin_iterate (GST_BIN (pipeline));
91  gst_bin_iterate (GST_BIN (pipeline));
92  gst_bin_iterate (GST_BIN (pipeline));
93
94  g_print ("cleaning up...\n");
95  gst_object_unref (GST_OBJECT (pipeline));
96  src = id1 = id2 = sink = pipeline = NULL;
97
98  g_print ("done.\n");
99  return 0;
100}
Note: See TracBrowser for help on using the repository browser.