2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 #include <gstfakesink.h>
27 GstElementDetails gst_fakesink_details = {
30 "Black hole for data",
32 "Erik Walthinsen <omega@cse.ogi.edu>",
37 /* FakeSink signals and args */
51 static void gst_fakesink_class_init (GstFakeSinkClass *klass);
52 static void gst_fakesink_init (GstFakeSink *fakesink);
54 static void gst_fakesink_set_arg (GtkObject *object, GtkArg *arg, guint id);
55 static void gst_fakesink_get_arg (GtkObject *object, GtkArg *arg, guint id);
57 static void gst_fakesink_chain (GstPad *pad,GstBuffer *buf);
59 static GstElementClass *parent_class = NULL;
60 static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
63 gst_fakesink_get_type (void)
65 static GtkType fakesink_type = 0;
68 static const GtkTypeInfo fakesink_info = {
71 sizeof(GstFakeSinkClass),
72 (GtkClassInitFunc)gst_fakesink_class_init,
73 (GtkObjectInitFunc)gst_fakesink_init,
76 (GtkClassInitFunc)NULL,
78 fakesink_type = gtk_type_unique (GST_TYPE_ELEMENT, &fakesink_info);
84 gst_fakesink_class_init (GstFakeSinkClass *klass)
86 GtkObjectClass *gtkobject_class;
88 gtkobject_class = (GtkObjectClass*)klass;
90 parent_class = gtk_type_class (GST_TYPE_ELEMENT);
92 gtk_object_add_arg_type ("GstFakeSink::num_sources", GTK_TYPE_INT,
93 GTK_ARG_READWRITE, ARG_NUM_SOURCES);
94 gtk_object_add_arg_type ("GstFakeSink::silent", GTK_TYPE_BOOL,
95 GTK_ARG_READWRITE, ARG_SILENT);
97 gst_fakesink_signals[SIGNAL_HANDOFF] =
98 gtk_signal_new ("handoff", GTK_RUN_LAST, gtkobject_class->type,
99 GTK_SIGNAL_OFFSET (GstFakeSinkClass, handoff),
100 gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
102 gtk_object_class_add_signals (gtkobject_class, gst_fakesink_signals,
105 gtkobject_class->set_arg = gst_fakesink_set_arg;
106 gtkobject_class->get_arg = gst_fakesink_get_arg;
110 gst_fakesink_init (GstFakeSink *fakesink)
113 pad = gst_pad_new ("sink", GST_PAD_SINK);
114 gst_element_add_pad (GST_ELEMENT (fakesink), pad);
115 gst_pad_set_chain_function (pad, gst_fakesink_chain);
116 fakesink->sinkpads = g_slist_prepend (NULL, pad);
117 fakesink->numsinkpads = 1;
118 fakesink->silent = FALSE;
120 // we're ready right away, since we don't have any args...
121 // gst_element_set_state(GST_ELEMENT(fakesink),GST_STATE_READY);
125 gst_fakesink_set_arg (GtkObject *object, GtkArg *arg, guint id)
131 /* it's not null if we got it, but it might not be ours */
132 sink = GST_FAKESINK (object);
135 case ARG_NUM_SOURCES:
136 new_numsinks = GTK_VALUE_INT (*arg);
137 while (sink->numsinkpads < new_numsinks) {
138 pad = gst_pad_new (g_strdup_printf ("sink%d", sink->numsinkpads), GST_PAD_SINK);
139 gst_pad_set_chain_function (pad, gst_fakesink_chain);
140 gst_element_add_pad (GST_ELEMENT (sink), pad);
141 sink->sinkpads = g_slist_append (sink->sinkpads, pad);
146 sink->silent = GTK_VALUE_BOOL (*arg);
154 gst_fakesink_get_arg (GtkObject *object, GtkArg *arg, guint id)
158 /* it's not null if we got it, but it might not be ours */
159 g_return_if_fail (GST_IS_FAKESINK (object));
161 sink = GST_FAKESINK (object);
164 case ARG_NUM_SOURCES:
165 GTK_VALUE_INT (*arg) = sink->numsinkpads;
168 GTK_VALUE_BOOL (*arg) = sink->silent;
171 arg->type = GTK_TYPE_INVALID;
177 * gst_fakesink_chain:
178 * @pad: the pad this faksink is connected to
179 * @buf: the buffer that has to be absorbed
181 * take the buffer from the pad and unref it without doing
185 gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
187 GstFakeSink *fakesink;
189 g_return_if_fail (pad != NULL);
190 g_return_if_fail (GST_IS_PAD (pad));
191 g_return_if_fail (buf != NULL);
193 fakesink = GST_FAKESINK (gst_pad_get_parent (pad));
194 if (!fakesink->silent)
195 g_print("fakesink: ******* (%s:%s)< \n",GST_DEBUG_PAD_NAME(pad));
197 gst_buffer_unref (buf);
199 gtk_signal_emit (GTK_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF],