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

Revision 21005, 2.3 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 Benjamin Otte <in7y118@public.uni-hamburg.de>
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 <gst/gst.h>
20
21GstElement *pipeline, *src, *sink;
22
23static void
24cb_handoff (GstElement * element, GstBuffer * buffer, GstPad * pad,
25    gpointer unused)
26{
27  if (GST_PAD_PEER (pad)) {
28    g_print ("relinking...\n");
29    gst_pad_unlink (pad, GST_PAD_PEER (pad));
30    gst_bin_remove (GST_BIN (pipeline), OTHER_ELEMENT);
31    OTHER_ELEMENT =
32        gst_element_factory_make ("fake" G_STRINGIFY (OTHER_ELEMENT), NULL);
33    g_assert (OTHER_ELEMENT);
34    gst_bin_add (GST_BIN (pipeline), OTHER_ELEMENT);
35    gst_element_sync_state_with_parent (OTHER_ELEMENT);
36    gst_element_link (ELEMENT, OTHER_ELEMENT);
37  }
38}
39
40gint
41main (gint argc, gchar ** argv)
42{
43  guint i = 0;
44
45  gst_init (&argc, &argv);
46
47  g_print ("setting up...\n");
48  /* setup pipeline */
49  pipeline = gst_element_factory_make ("pipeline", NULL);
50  g_assert (pipeline);
51  src = gst_element_factory_make ("fakesrc", NULL);
52  g_assert (src);
53  sink = gst_element_factory_make ("fakesink", NULL);
54  g_assert (sink);
55  gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
56  gst_element_link (src, sink);
57  /* setup special stuff */
58  g_object_set (ELEMENT, "signal-handoffs", TRUE, NULL);
59  g_signal_connect (ELEMENT, "handoff", (GCallback) cb_handoff, NULL);
60
61  /* run pipeline */
62  g_print ("running...\n");
63  if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
64    g_assert_not_reached ();
65  while (i++ < 10 && gst_bin_iterate (GST_BIN (pipeline)));
66
67  g_print ("cleaning up...\n");
68  gst_object_unref (GST_OBJECT (pipeline));
69  pipeline = NULL;
70
71  g_print ("done.\n");
72  return 0;
73}
Note: See TracBrowser for help on using the repository browser.