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 <gstidentity.h>
27 GstElementDetails gst_identity_details = {
30 "Pass data without modification",
32 "Erik Walthinsen <omega@cse.ogi.edu>",
37 /* Identity signals and args */
50 static void gst_identity_class_init (GstIdentityClass *klass);
51 static void gst_identity_init (GstIdentity *identity);
53 static void gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id);
54 static void gst_identity_get_arg (GtkObject *object, GtkArg *arg, guint id);
56 static void gst_identity_chain (GstPad *pad, GstBuffer *buf);
58 static GstElementClass *parent_class = NULL;
59 //static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
62 gst_identity_get_type (void)
64 static GtkType identity_type = 0;
67 static const GtkTypeInfo identity_info = {
70 sizeof(GstIdentityClass),
71 (GtkClassInitFunc)gst_identity_class_init,
72 (GtkObjectInitFunc)gst_identity_init,
73 (GtkArgSetFunc)gst_identity_set_arg,
74 (GtkArgGetFunc)gst_identity_get_arg,
75 (GtkClassInitFunc)NULL,
77 identity_type = gtk_type_unique (GST_TYPE_ELEMENT, &identity_info);
83 gst_identity_class_init (GstIdentityClass *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 ("GstIdentity::loop_based", GTK_TYPE_BOOL,
92 GTK_ARG_READWRITE, ARG_LOOP_BASED);
93 gtk_object_add_arg_type ("GstIdentity::sleep_time", GTK_TYPE_UINT,
94 GTK_ARG_READWRITE, ARG_SLEEP_TIME);
96 gtkobject_class->set_arg = gst_identity_set_arg;
97 gtkobject_class->get_arg = gst_identity_get_arg;
101 gst_identity_init (GstIdentity *identity)
103 identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
104 gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad);
105 gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain);
107 identity->srcpad = gst_pad_new ("src", GST_PAD_SRC);
108 gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
110 identity->loop_based = FALSE;
111 identity->sleep_time = 10000;
115 gst_identity_chain (GstPad *pad, GstBuffer *buf)
117 GstIdentity *identity;
119 g_return_if_fail (pad != NULL);
120 g_return_if_fail (GST_IS_PAD (pad));
121 g_return_if_fail (buf != NULL);
123 identity = GST_IDENTITY (pad->parent);
124 g_print("identity: ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(pad));
126 gst_pad_push (identity->srcpad, buf);
128 usleep (identity->sleep_time);
132 gst_identity_loop (GstElement *element)
134 GstIdentity *identity;
137 g_return_if_fail (element != NULL);
138 g_return_if_fail (GST_IS_IDENTITY (element));
140 identity = GST_IDENTITY (element);
143 buf = gst_pad_pull (identity->sinkpad);
144 g_print("identity: ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(identity->sinkpad));
146 gst_pad_push (identity->srcpad, buf);
148 usleep (identity->sleep_time);
150 } while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
154 gst_identity_set_arg (GtkObject *object, GtkArg *arg, guint id)
156 GstIdentity *identity;
158 /* it's not null if we got it, but it might not be ours */
159 g_return_if_fail (GST_IS_IDENTITY (object));
161 identity = GST_IDENTITY (object);
165 identity->loop_based = GTK_VALUE_BOOL (*arg);
166 if (identity->loop_based) {
167 gst_element_set_loop_function (GST_ELEMENT (identity), gst_identity_loop);
168 gst_pad_set_chain_function (identity->sinkpad, NULL);
171 gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain);
172 gst_element_set_loop_function (GST_ELEMENT (identity), NULL);
176 identity->sleep_time = GTK_VALUE_UINT (*arg);
183 static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id) {
184 GstIdentity *identity;
186 /* it's not null if we got it, but it might not be ours */
187 g_return_if_fail (GST_IS_IDENTITY (object));
189 identity = GST_IDENTITY (object);
193 GTK_VALUE_BOOL (*arg) = identity->loop_based;
196 GTK_VALUE_UINT (*arg) = identity->sleep_time;
199 arg->type = GTK_TYPE_INVALID;