1 /* Gnome-Streamer
2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library 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 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
21 #include <gstidentity.h>
24 GstElementDetails gst_identity_details = {
25 "Identity",
26 "Filter",
27 "Pass data without modification",
28 VERSION,
29 "Erik Walthinsen <omega@cse.ogi.edu>",
30 "(C) 1999",
31 };
34 /* Identity signals and args */
35 enum {
36 /* FILL ME */
37 LAST_SIGNAL
38 };
40 enum {
41 ARG_0,
42 ARG_CONTROL
43 };
46 static void gst_identity_class_init(GstIdentityClass *klass);
47 static void gst_identity_init(GstIdentity *identity);
48 static void gst_identity_set_arg(GtkObject *object,GtkArg *arg,guint id);
49 static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id);
52 static GstFilterClass *parent_class = NULL;
53 static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
55 GtkType
56 gst_identity_get_type(void) {
57 static GtkType identity_type = 0;
59 if (!identity_type) {
60 static const GtkTypeInfo identity_info = {
61 "GstIdentity",
62 sizeof(GstIdentity),
63 sizeof(GstIdentityClass),
64 (GtkClassInitFunc)gst_identity_class_init,
65 (GtkObjectInitFunc)gst_identity_init,
66 (GtkArgSetFunc)gst_identity_set_arg,
67 (GtkArgGetFunc)gst_identity_get_arg,
68 (GtkClassInitFunc)NULL,
69 };
70 identity_type = gtk_type_unique(GST_TYPE_FILTER,&identity_info);
71 }
72 return identity_type;
73 }
75 static void gst_identity_class_init(GstIdentityClass *klass) {
76 GtkObjectClass *gtkobject_class;
77 GstFilterClass *gstfilter_class;
79 gtkobject_class = (GtkObjectClass*)klass;
80 gstfilter_class = (GstFilterClass*)klass;
82 parent_class = gtk_type_class(GST_TYPE_FILTER);
84 gtk_object_add_arg_type("GstIdentity::control", GTK_TYPE_INT,
85 GTK_ARG_READWRITE, ARG_CONTROL);
87 gtkobject_class->set_arg = gst_identity_set_arg;
88 gtkobject_class->get_arg = gst_identity_get_arg;
89 }
91 static void gst_identity_init(GstIdentity *identity) {
92 identity->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
93 gst_element_add_pad(GST_ELEMENT(identity),identity->sinkpad);
94 gst_pad_set_chain_function(identity->sinkpad,gst_identity_chain);
95 identity->srcpad = gst_pad_new("src",GST_PAD_SRC);
96 gst_element_add_pad(GST_ELEMENT(identity),identity->srcpad);
98 identity->control = 0;
99 }
101 GstElement *gst_identity_new(gchar *name) {
102 GstElement *identity = GST_ELEMENT(gtk_type_new(GST_TYPE_IDENTITY));
103 gst_element_set_name(GST_ELEMENT(identity),name);
104 return identity;
105 }
107 void gst_identity_chain(GstPad *pad,GstBuffer *buf) {
108 GstIdentity *identity;
110 g_return_if_fail(pad != NULL);
111 g_return_if_fail(GST_IS_PAD(pad));
112 g_return_if_fail(buf != NULL);
114 identity = GST_IDENTITY(pad->parent);
115 // g_print("gst_identity_chain: got buffer in '%s'\n",
116 // gst_element_get_name(GST_ELEMENT(identity)));
117 g_print("i");
118 gst_pad_push(identity->srcpad,buf);
119 }
121 static void gst_identity_set_arg(GtkObject *object,GtkArg *arg,guint id) {
122 GstIdentity *identity;
124 /* it's not null if we got it, but it might not be ours */
125 g_return_if_fail(GST_IS_IDENTITY(object));
126 identity = GST_IDENTITY(object);
128 switch(id) {
129 case ARG_CONTROL:
130 identity->control = GTK_VALUE_INT(*arg);
131 break;
132 default:
133 break;
134 }
135 }
137 static void gst_identity_get_arg(GtkObject *object,GtkArg *arg,guint id) {
138 GstIdentity *identity;
140 /* it's not null if we got it, but it might not be ours */
141 g_return_if_fail(GST_IS_IDENTITY(object));
142 identity = GST_IDENTITY(object);
144 switch (id) {
145 case ARG_CONTROL:
146 GTK_VALUE_INT(*arg) = identity->control;
147 break;
148 default:
149 arg->type = GTK_TYPE_INVALID;
150 break;
151 }
152 }