diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2002-07-24 21:16:46 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2002-07-24 21:16:46 +0000 |
commit | 22c6519ec90699fa8fa030ce4b8e52073a82e3b4 (patch) | |
tree | 0bda9898142da504edd7c3d833b1b7371ae64657 /examples | |
parent | 75f15a288af33e03ba999c88a4bc58399c5da50c (diff) |
- Added a little testapp for pad disable using two bins in a pipeline
Original commit message from CVS:
- Added a little testapp for pad disable using two bins in a pipeline
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile.am | 4 | ||||
-rw-r--r-- | examples/pingpong/Makefile.am | 5 | ||||
-rw-r--r-- | examples/pingpong/pingpong.c | 113 |
3 files changed, 120 insertions, 2 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am index 2e4f7ae609..b834077cd7 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -7,10 +7,10 @@ endif SUBDIRS = autoplug $(GST_LOADSAVE_DIRS) \ helloworld helloworld2 \ queue queue2 queue3 queue4 \ - launch thread plugins mixer cutter + launch thread plugins mixer cutter pingpong DIST_SUBDIRS = autoplug \ helloworld helloworld2 \ queue queue2 queue3 queue4 \ - launch thread xml plugins typefind mixer cutter + launch thread xml plugins typefind mixer cutter pingpong diff --git a/examples/pingpong/Makefile.am b/examples/pingpong/Makefile.am new file mode 100644 index 0000000000..3bf9f161eb --- /dev/null +++ b/examples/pingpong/Makefile.am @@ -0,0 +1,5 @@ +noinst_PROGRAMS = pingpong + +pingpong_LDADD = $(GST_LIBS) +pingpong_CFLAGS = $(GST_CFLAGS) + diff --git a/examples/pingpong/pingpong.c b/examples/pingpong/pingpong.c new file mode 100644 index 0000000000..28e5cc6d31 --- /dev/null +++ b/examples/pingpong/pingpong.c @@ -0,0 +1,113 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <gst/gst.h> + +static GstElement* +make_bin (gint count) +{ + GstElement *bin; + GstElement *src; + + bin = gst_bin_new (g_strdup_printf ("bin%d", count)); + src = gst_element_factory_make ("fakesrc", g_strdup_printf ("fakesrc%d", count)); + + gst_bin_add (GST_BIN (bin), src); + + gst_element_add_ghost_pad (bin, gst_element_get_pad (src, "src"), "src"); + + return bin; +} + +static void +property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec, gpointer data) +{ + GValue value = { 0, }; /* the important thing is that value.type = 0 */ + gchar *str = 0; + + if (pspec->flags & G_PARAM_READABLE) { + /* let's not print these out for excluded properties... */ + g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + g_object_get_property (G_OBJECT (orig), pspec->name, &value); + str = g_strdup_value_contents (&value); + g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str); + g_free (str); + g_value_unset(&value); + } else { + g_warning ("Parameter not readable. What's up with that?"); + } +} + +gint +main (gint argc, gchar *argv[]) +{ + GstElement *pipeline; + GstElement *aggregator, *sink; + GstElement *bin1, *bin2; + GstPad *pad1, *pad2; + gint i; + + gst_init (&argc, &argv); + + pipeline = gst_pipeline_new ("main"); + g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL); + + aggregator = gst_element_factory_make ("aggregator", "mixer"); + sink = gst_element_factory_make ("fakesink", "sink"); + + gst_bin_add (GST_BIN (pipeline), aggregator); + gst_bin_add (GST_BIN (pipeline), sink); + + gst_element_connect_pads (aggregator, "src", sink, "sink"); + + bin1 = make_bin (1); + pad1 = gst_element_get_request_pad (aggregator, "sink%d"); + gst_pad_connect (gst_element_get_pad (bin1, "src"), pad1); + gst_bin_add (GST_BIN (pipeline), bin1); + + bin2 = make_bin (2); + pad2 = gst_element_get_request_pad (aggregator, "sink%d"); + gst_pad_connect (gst_element_get_pad (bin2, "src"), pad2); + gst_bin_add (GST_BIN (pipeline), bin2); + + gst_element_set_state (pipeline, GST_STATE_PLAYING); + i = 2; + while (i--) + gst_bin_iterate (GST_BIN (pipeline)); + + g_print ("pause bin1\n"); + gst_element_set_state (bin1, GST_STATE_PAUSED); + gst_pad_set_active (pad1, FALSE); + + i = 4; + while (i--) + gst_bin_iterate (GST_BIN (pipeline)); + + g_print ("playing bin1\n"); + gst_pad_set_active (pad1, TRUE); + gst_element_set_state (bin1, GST_STATE_PLAYING); + + i = 4; + while (i--) + gst_bin_iterate (GST_BIN (pipeline)); + + gst_element_set_state (pipeline, GST_STATE_NULL); + + return 0; +} |