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 */
50 static void gst_fakesink_class_init (GstFakeSinkClass *klass);
51 static void gst_fakesink_init (GstFakeSink *fakesink);
53 static void gst_fakesink_set_arg (GtkObject *object, GtkArg *arg, guint id);
54 static void gst_fakesink_get_arg (GtkObject *object, GtkArg *arg, guint id);
56 static void gst_fakesink_chain (GstPad *pad,GstBuffer *buf);
58 static GstElementClass *parent_class = NULL;
59 static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 };
62 gst_fakesink_get_type (void)
64 static GtkType fakesink_type = 0;
67 static const GtkTypeInfo fakesink_info = {
70 sizeof(GstFakeSinkClass),
71 (GtkClassInitFunc)gst_fakesink_class_init,
72 (GtkObjectInitFunc)gst_fakesink_init,
75 (GtkClassInitFunc)NULL,
77 fakesink_type = gtk_type_unique (GST_TYPE_ELEMENT, &fakesink_info);
83 gst_fakesink_class_init (GstFakeSinkClass *klass)
85 GtkObjectClass *gtkobject_class;
87 gtkobject_class = (GtkObjectClass*)klass;
89 parent_class = gtk_type_class (GST_TYPE_ELEMENT);
91 gtk_object_add_arg_type ("GstFakeSink::num_sources", GTK_TYPE_INT,
92 GTK_ARG_READWRITE, ARG_NUM_SOURCES);
94 gst_fakesink_signals[SIGNAL_HANDOFF] =
95 gtk_signal_new ("handoff", GTK_RUN_LAST, gtkobject_class->type,
96 GTK_SIGNAL_OFFSET (GstFakeSinkClass, handoff),
97 gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0);
99 gtk_object_class_add_signals (gtkobject_class, gst_fakesink_signals,
102 gtkobject_class->set_arg = gst_fakesink_set_arg;
103 gtkobject_class->get_arg = gst_fakesink_get_arg;
107 gst_fakesink_init (GstFakeSink *fakesink)
110 pad = gst_pad_new ("sink", GST_PAD_SINK);
111 gst_element_add_pad (GST_ELEMENT (fakesink), pad);
112 gst_pad_set_chain_function (pad, gst_fakesink_chain);
113 fakesink->sinkpads = g_slist_prepend (NULL, pad);
114 fakesink->numsinkpads = 1;
116 // we're ready right away, since we don't have any args...
117 // gst_element_set_state(GST_ELEMENT(fakesink),GST_STATE_READY);
121 gst_fakesink_set_arg (GtkObject *object, GtkArg *arg, guint id)
127 /* it's not null if we got it, but it might not be ours */
128 sink = GST_FAKESINK (object);
131 case ARG_NUM_SOURCES:
132 new_numsinks = GTK_VALUE_INT (*arg);
133 while (sink->numsinkpads < new_numsinks) {
134 pad = gst_pad_new (g_strdup_printf ("sink%d", sink->numsinkpads), GST_PAD_SINK);
135 gst_pad_set_chain_function (pad, gst_fakesink_chain);
136 gst_element_add_pad (GST_ELEMENT (sink), pad);
137 sink->sinkpads = g_slist_append (sink->sinkpads, pad);
147 gst_fakesink_get_arg (GtkObject *object, GtkArg *arg, guint id)
151 /* it's not null if we got it, but it might not be ours */
152 g_return_if_fail (GST_IS_FAKESINK (object));
154 sink = GST_FAKESINK (object);
157 case ARG_NUM_SOURCES:
158 GTK_VALUE_INT (*arg) = sink->numsinkpads;
161 arg->type = GTK_TYPE_INVALID;
167 * gst_fakesink_chain:
168 * @pad: the pad this faksink is connected to
169 * @buf: the buffer that has to be absorbed
171 * take the buffer from the pad and unref it without doing
175 gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
177 GstFakeSink *fakesink;
179 g_return_if_fail (pad != NULL);
180 g_return_if_fail (GST_IS_PAD (pad));
181 g_return_if_fail (buf != NULL);
183 fakesink = GST_FAKESINK (pad->parent);
184 g_print("fakesink: ******* (%s:%s)< \n",GST_DEBUG_PAD_NAME(pad));
186 gst_buffer_unref (buf);
188 gtk_signal_emit (GTK_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF],