*.c: Don't cast to GST_OBJECT when reffing or unreffing. Large source-munging commit!!!
[platform/upstream/gstreamer.git] / testsuite / schedulers / unlink.c
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
21 static void
22 cb_handoff (GstElement * element, GstBuffer * buffer, GstPad * pad,
23     gpointer unused)
24 {
25   if (GST_PAD_PEER (pad)) {
26     g_print ("unlinking...\n");
27     gst_pad_unlink (pad, GST_PAD_PEER (pad));
28   }
29 }
30
31 gint
32 main (gint argc, gchar ** argv)
33 {
34   GstElement *pipeline, *src, *sink;
35
36   gst_init (&argc, &argv);
37
38   g_print ("setting up...\n");
39   /* setup pipeline */
40   pipeline = gst_element_factory_make ("pipeline", NULL);
41   g_assert (pipeline);
42   src = gst_element_factory_make ("fakesrc", NULL);
43   g_assert (src);
44   sink = gst_element_factory_make ("fakesink", NULL);
45   g_assert (sink);
46   gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
47   gst_element_link (src, sink);
48   /* setup special stuff */
49   g_object_set (ELEMENT, "signal-handoffs", TRUE, NULL);
50   g_signal_connect (ELEMENT, "handoff", (GCallback) cb_handoff, NULL);
51
52   /* run pipeline */
53   g_print ("running...\n");
54   if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
55     g_assert_not_reached ();
56   while (gst_bin_iterate (GST_BIN (pipeline)));
57
58   g_print ("cleaning up...\n");
59   gst_object_unref (pipeline);
60   pipeline = NULL;
61
62   g_print ("done.\n");
63   return 0;
64 }