2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
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.
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.
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.
22 /* elementfactory information */
23 static GstElementDetails example_details = {
26 "Shows the basic structure of a plugin",
28 "your name <your.name@your.isp>",
32 /* Example signals and args */
43 static GstPadFactory sink_factory = {
44 "sink", /* the name of the pads */
45 GST_PAD_FACTORY_SINK, /* type of the pad */
46 GST_PAD_FACTORY_ALWAYS, /* ALWAYS/SOMETIMES */
48 "example_sink", /* the name of the caps */
49 "unknown/unknown", /* the mime type of the caps */
50 "something", GST_PROPS_INT (1), /* a property */
51 "foo", GST_PROPS_BOOLEAN (TRUE) /* another property */
56 static GstPadFactory src_factory = {
59 GST_PAD_FACTORY_ALWAYS,
68 static void gst_example_class_init (GstExampleClass *klass);
69 static void gst_example_init (GstExample *example);
71 static void gst_example_chain (GstPad *pad, GstBuffer *buf);
73 static void gst_example_set_arg (GtkObject *object,GtkArg *arg,guint id);
74 static void gst_example_get_arg (GtkObject *object,GtkArg *arg,guint id);
76 GstPadTemplate *src_template, *sink_template;
78 static GstElementClass *parent_class = NULL;
79 //static guint gst_example_signals[LAST_SIGNAL] = { 0 };
82 gst_example_get_type(void)
84 static GtkType example_type = 0;
87 static const GtkTypeInfo example_info = {
90 sizeof(GstExampleClass),
91 (GtkClassInitFunc)gst_example_class_init,
92 (GtkObjectInitFunc)gst_example_init,
93 (GtkArgSetFunc)gst_example_set_arg,
94 (GtkArgGetFunc)gst_example_get_arg,
95 (GtkClassInitFunc)NULL,
97 example_type = gtk_type_unique(GST_TYPE_ELEMENT,&example_info);
103 gst_example_class_init (GstExampleClass *klass)
105 GtkObjectClass *gtkobject_class;
106 GstElementClass *gstelement_class;
108 gtkobject_class = (GtkObjectClass*)klass;
109 gstelement_class = (GstElementClass*)klass;
111 parent_class = gtk_type_class(GST_TYPE_ELEMENT);
113 gtk_object_add_arg_type("GstExample::active", GTK_TYPE_INT,
114 GTK_ARG_READWRITE, ARG_ACTIVE);
116 gtkobject_class->set_arg = gst_example_set_arg;
117 gtkobject_class->get_arg = gst_example_get_arg;
121 gst_example_init(GstExample *example)
123 example->sinkpad = gst_pad_new_from_template (sink_template, "sink");
124 gst_element_add_pad(GST_ELEMENT(example),example->sinkpad);
125 gst_pad_set_chain_function(example->sinkpad,gst_example_chain);
127 example->srcpad = gst_pad_new_from_template (src_template, "src");
128 gst_element_add_pad(GST_ELEMENT(example),example->srcpad);
130 example->active = FALSE;
134 gst_example_chain (GstPad *pad, GstBuffer *buf)
138 g_return_if_fail(pad != NULL);
139 g_return_if_fail(GST_IS_PAD(pad));
140 g_return_if_fail(buf != NULL);
141 //g_return_if_fail(GST_IS_BUFFER(buf));
143 example = GST_EXAMPLE(gst_pad_get_parent (pad));
145 g_return_if_fail(example != NULL);
146 g_return_if_fail(GST_IS_EXAMPLE(example));
148 if (example->active) {
152 gst_pad_push(example->srcpad,buf);
156 gst_example_set_arg (GtkObject *object,GtkArg *arg,guint id)
160 /* it's not null if we got it, but it might not be ours */
161 g_return_if_fail(GST_IS_EXAMPLE(object));
162 example = GST_EXAMPLE(object);
166 example->active = GTK_VALUE_INT(*arg);
167 g_print("example: set active to %d\n",example->active);
175 gst_example_get_arg (GtkObject *object,GtkArg *arg,guint id)
179 /* it's not null if we got it, but it might not be ours */
180 g_return_if_fail(GST_IS_EXAMPLE(object));
181 example = GST_EXAMPLE(object);
185 GTK_VALUE_INT(*arg) = example->active;
188 arg->type = GTK_TYPE_INVALID;
194 plugin_init (GModule *module)
197 GstElementFactory *factory;
199 plugin = gst_plugin_new("example");
200 g_return_val_if_fail(plugin != NULL, NULL);
202 factory = gst_elementfactory_new("example", GST_TYPE_EXAMPLE, &example_details);
203 g_return_val_if_fail(factory != NULL, NULL);
205 sink_template = gst_padtemplate_new (&sink_factory);
206 gst_elementfactory_add_padtemplate (factory, sink_template);
208 src_template = gst_padtemplate_new (&src_factory);
209 gst_elementfactory_add_padtemplate (factory, src_template);
211 gst_plugin_add_factory (plugin, factory);