From c12e795dec02ca775713d132f9f0e773407f16cf Mon Sep 17 00:00:00 2001 From: Richard Boulton Date: Mon, 8 Jan 2001 23:55:27 +0000 Subject: [PATCH] Move plugin example code to new location, and put it into build system. Original commit message from CVS: Move plugin example code to new location, and put it into build system. Add work on firstplugin chapter of pwg. Fix typo in quotes. Add @'s before commands in manuals.mak --- configure.in | 1 + docs/fwg/Makefile.am | 3 +- docs/fwg/firstplugin.sgml | 128 +++++++++++++++ docs/fwg/gst-plugin-writers-guide.sgml | 22 +-- docs/fwg/titlepage.sgml | 1 + docs/manual/quotes.sgml | 3 +- docs/manuals.mak | 6 +- examples/Makefile.am | 2 +- examples/plugins/.gitignore | 7 + examples/plugins/Makefile.am | 8 + examples/plugins/example.c | 216 +++++++++++++++++++++++++ examples/plugins/example.h | 68 ++++++++ tests/old/examples/Makefile.am | 2 +- tests/old/examples/plugins/.gitignore | 7 + tests/old/examples/plugins/Makefile.am | 8 + tests/old/examples/plugins/example.c | 216 +++++++++++++++++++++++++ tests/old/examples/plugins/example.h | 68 ++++++++ 17 files changed, 744 insertions(+), 22 deletions(-) create mode 100644 docs/fwg/firstplugin.sgml create mode 100644 examples/plugins/.gitignore create mode 100644 examples/plugins/Makefile.am create mode 100644 examples/plugins/example.c create mode 100644 examples/plugins/example.h create mode 100644 tests/old/examples/plugins/.gitignore create mode 100644 tests/old/examples/plugins/Makefile.am create mode 100644 tests/old/examples/plugins/example.c create mode 100644 tests/old/examples/plugins/example.h diff --git a/configure.in b/configure.in index 63eb940397..9e2df0ed01 100644 --- a/configure.in +++ b/configure.in @@ -664,6 +664,7 @@ examples/queue4/Makefile examples/thread/Makefile examples/launch/Makefile examples/xml/Makefile +examples/plugins/Makefile editor/Makefile editor/pixmaps/Makefile tools/Makefile diff --git a/docs/fwg/Makefile.am b/docs/fwg/Makefile.am index 55b2ea93c7..4450f5689d 100644 --- a/docs/fwg/Makefile.am +++ b/docs/fwg/Makefile.am @@ -4,7 +4,8 @@ htmlname = index.html sgml_files = gst-plugin-writers-guide.sgml \ titlepage.sgml \ intro.sgml \ - concepts.sgml + concepts.sgml \ + firstplugin.sgml fig_files = eps_files = diff --git a/docs/fwg/firstplugin.sgml b/docs/fwg/firstplugin.sgml new file mode 100644 index 0000000000..ef54027c77 --- /dev/null +++ b/docs/fwg/firstplugin.sgml @@ -0,0 +1,128 @@ + + Constructing the boilerplate + + The first thing to do when making a new element is to specify some basic + details about it: what its name is, who wrote it, what version number it + is, etc. We also need to define an object to represent the element and to + store the data the element needs. I shall refer to these details + collectively as the boilerplate. + + + + Doing it the hard way with GstObject + + The standard way of defining the boilerplate is simply to write some + code, and fill in some structures. The easiest way to do this is to + copy an example and modify according to your needs. + + + First we will examine the code you would be likely to place in a header + file (although since the interface to the code is entirely defined + by the pluging system, and doesn't depend on reading a header file, + this is not crucial.) + + The code here can be found in + examples/plugins/example.h + + + + /* Definition of structure storing data for this element. */ + typedef struct _GstExample GstExample; + struct _GstExample { + GstElement element; + + GstPad *sinkpad,*srcpad; + + gint8 active; + }; + + /* Standard definition defining a class for this element. */ + typedef struct _GstExampleClass GstExampleClass; + struct _GstExampleClass { + GstElementClass parent_class; + }; + + /* Standard macros for defining types for this element. */ + #define GST_TYPE_EXAMPLE \ + (gst_example_get_type()) + #define GST_EXAMPLE(obj) \ + (GTK_CHECK_CAST((obj),GST_TYPE_EXAMPLE,GstExample)) + #define GST_EXAMPLE_CLASS(klass) \ + (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_EXAMPLE,GstExample)) + #define GST_IS_EXAMPLE(obj) \ + (GTK_CHECK_TYPE((obj),GST_TYPE_EXAMPLE)) + #define GST_IS_EXAMPLE_CLASS(obj) \ + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EXAMPLE)) + + /* Standard function returning type information. */ + GtkType gst_example_get_type(void); + + + + + + Doing it the easy way with FilterFactory + + A plan for the future is to create a FilterFactory, to make the + process of making a new filter a simple process of specifying a few + details, and writing a small amount of code to perform the actual + data processing. + + + Unfortunately, this hasn't yet been implemented. It is also likely + that when it is, it will not be possible to cover all the possibilities + available by writing the boilerplate yourself, so some plugins will + always need to be manually registered. + + + + + + An identity filter + + + + + Building an object with pads + + + + + + Attaching functions + + + + + + + The chain function + + + + + + + The plugin_init function + + + + + Registering the types + + + + + + Registering the filter + + + + + + + Having multiple filters in a single plugin + + + + diff --git a/docs/fwg/gst-plugin-writers-guide.sgml b/docs/fwg/gst-plugin-writers-guide.sgml index c09ca77932..e6bcef6814 100644 --- a/docs/fwg/gst-plugin-writers-guide.sgml +++ b/docs/fwg/gst-plugin-writers-guide.sgml @@ -5,7 +5,7 @@ - + @@ -76,24 +76,18 @@ We are now have the neccessary concepts to build our first plugin. We are going to build an element which has a single input pad and a single output pad, and simply passes anything it reads on - the input pad through and out on the output pad. In a later - section we will convert this plugin into something less useless. + the input pad through and out on the output pad. We will also + see where we could add code to convert this plugin into something + more useful. + + + The example code used in this section can be found in + examples/plugins/ &FIRSTPLUGIN; - Constructing the boilerplate - Doing it the easy way with FilterFactory - (NOTE: FilterFactory doesn't exist yet) - Doing it the hard way with G[tk]Object - An identity filter - Building an object with pads - Attaching functions - The chain function - The plugin_init function - Registering the types - Registering the filter diff --git a/docs/fwg/titlepage.sgml b/docs/fwg/titlepage.sgml index 72616d18c4..6893a4b9f1 100644 --- a/docs/fwg/titlepage.sgml +++ b/docs/fwg/titlepage.sgml @@ -3,6 +3,7 @@ Richard + John Boulton diff --git a/docs/manual/quotes.sgml b/docs/manual/quotes.sgml index dc5f82f3f7..d7645d2dfb 100644 --- a/docs/manual/quotes.sgml +++ b/docs/manual/quotes.sgml @@ -7,8 +7,7 @@ We often hang out on the #gstreamer IRC channel on irc.openprojects.net: the following are a selection of amusing No guarantee of sense of humour compatibility is given. - quotes - from our conversations. + quotes from our conversations. diff --git a/docs/manuals.mak b/docs/manuals.mak index dcdd1f044d..7ebdb15ff5 100644 --- a/docs/manuals.mak +++ b/docs/manuals.mak @@ -19,14 +19,14 @@ endif if HAVE_DB2HTML db2html $(manualname).sgml else - echo "Can't build $@: don't have db2html tool" + @echo "Can't build $@: don't have db2html tool" endif $(manualname).pdf: $(manualname).ps if HAVE_PS2PDF @if [ -r $< ] ; then ps2pdf $< $@ ; fi else - echo "Can't build $@: don't have ps2pdf tool" + @echo "Can't build $@: don't have ps2pdf tool" endif if HAVE_FIG2DEV_EPS @@ -37,7 +37,7 @@ endif if HAVE_DB2PS @if [ -r $< ] ; then db2ps $(manualname).sgml ; fi else - echo "Can't build $@: don't have db2ps tool" + @echo "Can't build $@: don't have db2ps tool" endif images : diff --git a/examples/Makefile.am b/examples/Makefile.am index a4716ec4d0..1b5d86647b 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,4 +1,4 @@ SUBDIRS = autoplug \ helloworld helloworld2 \ queue queue2 queue3 queue4 \ - launch thread xml + launch thread xml plugins diff --git a/examples/plugins/.gitignore b/examples/plugins/.gitignore new file mode 100644 index 0000000000..08f5ed37d8 --- /dev/null +++ b/examples/plugins/.gitignore @@ -0,0 +1,7 @@ +Makefile +Makefile.in +*.o +*.lo +*.la +.deps +.libs diff --git a/examples/plugins/Makefile.am b/examples/plugins/Makefile.am new file mode 100644 index 0000000000..d01c636785 --- /dev/null +++ b/examples/plugins/Makefile.am @@ -0,0 +1,8 @@ +noinst_LTLIBRARIES = libexample.la + +libexample_la_SOURCES = example.c +noinst_HEADERS = example.h + +INCLUDES = $(GLIB_CFLAGS) $(GTK_CFLAGS) -I$(top_srcdir) + +libexample_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) diff --git a/examples/plugins/example.c b/examples/plugins/example.c new file mode 100644 index 0000000000..c3f534e281 --- /dev/null +++ b/examples/plugins/example.c @@ -0,0 +1,216 @@ +/* Gnome-Streamer + * Copyright (C) <1999> Erik Walthinsen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "example.h" + +/* elementfactory information */ +static GstElementDetails example_details = { + "An example plugin", + "Example", + "Shows the basic structure of a plugin", + VERSION, + "your name ", + "(C) 2000", +}; + +/* Example signals and args */ +enum { + /* FILL ME */ + LAST_SIGNAL +}; + +enum { + ARG_0, + ARG_ACTIVE +}; + +static GstPadFactory sink_factory = { + "sink", /* the name of the pads */ + GST_PAD_FACTORY_SINK, /* type of the pad */ + GST_PAD_FACTORY_ALWAYS, /* ALWAYS/SOMETIMES */ + GST_PAD_FACTORY_CAPS( + "example_sink", /* the name of the caps */ + "unknown/unknown", /* the mime type of the caps */ + "something", GST_PROPS_INT (1), /* a property */ + "foo", GST_PROPS_BOOLEAN (TRUE) /* another property */ + ), + NULL +}; + +static GstPadFactory src_factory = { + "src", + GST_PAD_FACTORY_SRC, + GST_PAD_FACTORY_ALWAYS, + GST_PAD_FACTORY_CAPS( + "example_src", + "unknown/unknown" + ), + NULL +}; + + +static void gst_example_class_init (GstExampleClass *klass); +static void gst_example_init (GstExample *example); + +static void gst_example_chain (GstPad *pad, GstBuffer *buf); + +static void gst_example_set_arg (GtkObject *object,GtkArg *arg,guint id); +static void gst_example_get_arg (GtkObject *object,GtkArg *arg,guint id); + +GstPadTemplate *src_template, *sink_template; + +static GstElementClass *parent_class = NULL; +static guint gst_example_signals[LAST_SIGNAL] = { 0 }; + +GtkType +gst_example_get_type(void) +{ + static GtkType example_type = 0; + + if (!example_type) { + static const GtkTypeInfo example_info = { + "GstExample", + sizeof(GstExample), + sizeof(GstExampleClass), + (GtkClassInitFunc)gst_example_class_init, + (GtkObjectInitFunc)gst_example_init, + (GtkArgSetFunc)gst_example_set_arg, + (GtkArgGetFunc)gst_example_get_arg, + (GtkClassInitFunc)NULL, + }; + example_type = gtk_type_unique(GST_TYPE_ELEMENT,&example_info); + } + return example_type; +} + +static void +gst_example_class_init (GstExampleClass *klass) +{ + GtkObjectClass *gtkobject_class; + GstElementClass *gstelement_class; + + gtkobject_class = (GtkObjectClass*)klass; + gstelement_class = (GstElementClass*)klass; + + parent_class = gtk_type_class(GST_TYPE_ELEMENT); + + gtk_object_add_arg_type("GstExample::active", GTK_TYPE_INT, + GTK_ARG_READWRITE, ARG_ACTIVE); + + gtkobject_class->set_arg = gst_example_set_arg; + gtkobject_class->get_arg = gst_example_get_arg; +} + +static void +gst_example_init(GstExample *example) +{ + example->sinkpad = gst_pad_new_from_template (sink_template, "sink"); + gst_element_add_pad(GST_ELEMENT(example),example->sinkpad); + gst_pad_set_chain_function(example->sinkpad,gst_example_chain); + + example->srcpad = gst_pad_new_from_template (src_template, "src"); + gst_element_add_pad(GST_ELEMENT(example),example->srcpad); + + example->active = FALSE; +} + +static void +gst_example_chain (GstPad *pad, GstBuffer *buf) +{ + GstExample *example; + guchar *data; + gint i; + + g_return_if_fail(pad != NULL); + g_return_if_fail(GST_IS_PAD(pad)); + g_return_if_fail(buf != NULL); + //g_return_if_fail(GST_IS_BUFFER(buf)); + + example = GST_EXAMPLE(pad->parent); + + g_return_if_fail(example != NULL); + g_return_if_fail(GST_IS_EXAMPLE(example)); + + if (example->active) { + /* DO STUFF */ + } + + gst_pad_push(example->srcpad,buf); +} + +static void +gst_example_set_arg (GtkObject *object,GtkArg *arg,guint id) +{ + GstExample *example; + + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail(GST_IS_EXAMPLE(object)); + example = GST_EXAMPLE(object); + + switch(id) { + case ARG_ACTIVE: + example->active = GTK_VALUE_INT(*arg); + g_print("example: set active to %d\n",example->active); + break; + default: + break; + } +} + +static void +gst_example_get_arg (GtkObject *object,GtkArg *arg,guint id) +{ + GstExample *example; + + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail(GST_IS_EXAMPLE(object)); + example = GST_EXAMPLE(object); + + switch (id) { + case ARG_ACTIVE: + GTK_VALUE_INT(*arg) = example->active; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +GstPlugin* +plugin_init (GModule *module) +{ + GstPlugin *plugin; + GstElementFactory *factory; + + plugin = gst_plugin_new("example"); + g_return_if_fail(plugin != NULL); + + factory = gst_elementfactory_new("example", GST_TYPE_EXAMPLE, &example_details); + g_return_if_fail(factory != NULL); + + sink_template = gst_padtemplate_new (&sink_factory); + gst_elementfactory_add_padtemplate (factory, sink_template); + + src_template = gst_padtemplate_new (&src_factory); + gst_elementfactory_add_padtemplate (factory, src_template); + + gst_plugin_add_factory (plugin, factory); + + return plugin; +} diff --git a/examples/plugins/example.h b/examples/plugins/example.h new file mode 100644 index 0000000000..a04f5ba297 --- /dev/null +++ b/examples/plugins/example.h @@ -0,0 +1,68 @@ +/* Gnome-Streamer + * Copyright (C) <1999> Erik Walthinsen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#ifndef __GST_EXAMPLE_H__ +#define __GST_EXAMPLE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* Definition of structure storing data for this element. */ +typedef struct _GstExample GstExample; +struct _GstExample { + GstElement element; + + GstPad *sinkpad,*srcpad; + + gint8 active; +}; + +/* Standard definition defining a class for this element. */ +typedef struct _GstExampleClass GstExampleClass; +struct _GstExampleClass { + GstElementClass parent_class; +}; + +/* Standard macros for defining types for this element. */ +#define GST_TYPE_EXAMPLE \ + (gst_example_get_type()) +#define GST_EXAMPLE(obj) \ + (GTK_CHECK_CAST((obj),GST_TYPE_EXAMPLE,GstExample)) +#define GST_EXAMPLE_CLASS(klass) \ + (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_EXAMPLE,GstExample)) +#define GST_IS_EXAMPLE(obj) \ + (GTK_CHECK_TYPE((obj),GST_TYPE_EXAMPLE)) +#define GST_IS_EXAMPLE_CLASS(obj) \ + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EXAMPLE)) + +/* Standard function returning type information. */ +GtkType gst_example_get_type(void); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __GST_EXAMPLE_H__ */ diff --git a/tests/old/examples/Makefile.am b/tests/old/examples/Makefile.am index a4716ec4d0..1b5d86647b 100644 --- a/tests/old/examples/Makefile.am +++ b/tests/old/examples/Makefile.am @@ -1,4 +1,4 @@ SUBDIRS = autoplug \ helloworld helloworld2 \ queue queue2 queue3 queue4 \ - launch thread xml + launch thread xml plugins diff --git a/tests/old/examples/plugins/.gitignore b/tests/old/examples/plugins/.gitignore new file mode 100644 index 0000000000..08f5ed37d8 --- /dev/null +++ b/tests/old/examples/plugins/.gitignore @@ -0,0 +1,7 @@ +Makefile +Makefile.in +*.o +*.lo +*.la +.deps +.libs diff --git a/tests/old/examples/plugins/Makefile.am b/tests/old/examples/plugins/Makefile.am new file mode 100644 index 0000000000..d01c636785 --- /dev/null +++ b/tests/old/examples/plugins/Makefile.am @@ -0,0 +1,8 @@ +noinst_LTLIBRARIES = libexample.la + +libexample_la_SOURCES = example.c +noinst_HEADERS = example.h + +INCLUDES = $(GLIB_CFLAGS) $(GTK_CFLAGS) -I$(top_srcdir) + +libexample_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) diff --git a/tests/old/examples/plugins/example.c b/tests/old/examples/plugins/example.c new file mode 100644 index 0000000000..c3f534e281 --- /dev/null +++ b/tests/old/examples/plugins/example.c @@ -0,0 +1,216 @@ +/* Gnome-Streamer + * Copyright (C) <1999> Erik Walthinsen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "example.h" + +/* elementfactory information */ +static GstElementDetails example_details = { + "An example plugin", + "Example", + "Shows the basic structure of a plugin", + VERSION, + "your name ", + "(C) 2000", +}; + +/* Example signals and args */ +enum { + /* FILL ME */ + LAST_SIGNAL +}; + +enum { + ARG_0, + ARG_ACTIVE +}; + +static GstPadFactory sink_factory = { + "sink", /* the name of the pads */ + GST_PAD_FACTORY_SINK, /* type of the pad */ + GST_PAD_FACTORY_ALWAYS, /* ALWAYS/SOMETIMES */ + GST_PAD_FACTORY_CAPS( + "example_sink", /* the name of the caps */ + "unknown/unknown", /* the mime type of the caps */ + "something", GST_PROPS_INT (1), /* a property */ + "foo", GST_PROPS_BOOLEAN (TRUE) /* another property */ + ), + NULL +}; + +static GstPadFactory src_factory = { + "src", + GST_PAD_FACTORY_SRC, + GST_PAD_FACTORY_ALWAYS, + GST_PAD_FACTORY_CAPS( + "example_src", + "unknown/unknown" + ), + NULL +}; + + +static void gst_example_class_init (GstExampleClass *klass); +static void gst_example_init (GstExample *example); + +static void gst_example_chain (GstPad *pad, GstBuffer *buf); + +static void gst_example_set_arg (GtkObject *object,GtkArg *arg,guint id); +static void gst_example_get_arg (GtkObject *object,GtkArg *arg,guint id); + +GstPadTemplate *src_template, *sink_template; + +static GstElementClass *parent_class = NULL; +static guint gst_example_signals[LAST_SIGNAL] = { 0 }; + +GtkType +gst_example_get_type(void) +{ + static GtkType example_type = 0; + + if (!example_type) { + static const GtkTypeInfo example_info = { + "GstExample", + sizeof(GstExample), + sizeof(GstExampleClass), + (GtkClassInitFunc)gst_example_class_init, + (GtkObjectInitFunc)gst_example_init, + (GtkArgSetFunc)gst_example_set_arg, + (GtkArgGetFunc)gst_example_get_arg, + (GtkClassInitFunc)NULL, + }; + example_type = gtk_type_unique(GST_TYPE_ELEMENT,&example_info); + } + return example_type; +} + +static void +gst_example_class_init (GstExampleClass *klass) +{ + GtkObjectClass *gtkobject_class; + GstElementClass *gstelement_class; + + gtkobject_class = (GtkObjectClass*)klass; + gstelement_class = (GstElementClass*)klass; + + parent_class = gtk_type_class(GST_TYPE_ELEMENT); + + gtk_object_add_arg_type("GstExample::active", GTK_TYPE_INT, + GTK_ARG_READWRITE, ARG_ACTIVE); + + gtkobject_class->set_arg = gst_example_set_arg; + gtkobject_class->get_arg = gst_example_get_arg; +} + +static void +gst_example_init(GstExample *example) +{ + example->sinkpad = gst_pad_new_from_template (sink_template, "sink"); + gst_element_add_pad(GST_ELEMENT(example),example->sinkpad); + gst_pad_set_chain_function(example->sinkpad,gst_example_chain); + + example->srcpad = gst_pad_new_from_template (src_template, "src"); + gst_element_add_pad(GST_ELEMENT(example),example->srcpad); + + example->active = FALSE; +} + +static void +gst_example_chain (GstPad *pad, GstBuffer *buf) +{ + GstExample *example; + guchar *data; + gint i; + + g_return_if_fail(pad != NULL); + g_return_if_fail(GST_IS_PAD(pad)); + g_return_if_fail(buf != NULL); + //g_return_if_fail(GST_IS_BUFFER(buf)); + + example = GST_EXAMPLE(pad->parent); + + g_return_if_fail(example != NULL); + g_return_if_fail(GST_IS_EXAMPLE(example)); + + if (example->active) { + /* DO STUFF */ + } + + gst_pad_push(example->srcpad,buf); +} + +static void +gst_example_set_arg (GtkObject *object,GtkArg *arg,guint id) +{ + GstExample *example; + + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail(GST_IS_EXAMPLE(object)); + example = GST_EXAMPLE(object); + + switch(id) { + case ARG_ACTIVE: + example->active = GTK_VALUE_INT(*arg); + g_print("example: set active to %d\n",example->active); + break; + default: + break; + } +} + +static void +gst_example_get_arg (GtkObject *object,GtkArg *arg,guint id) +{ + GstExample *example; + + /* it's not null if we got it, but it might not be ours */ + g_return_if_fail(GST_IS_EXAMPLE(object)); + example = GST_EXAMPLE(object); + + switch (id) { + case ARG_ACTIVE: + GTK_VALUE_INT(*arg) = example->active; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +GstPlugin* +plugin_init (GModule *module) +{ + GstPlugin *plugin; + GstElementFactory *factory; + + plugin = gst_plugin_new("example"); + g_return_if_fail(plugin != NULL); + + factory = gst_elementfactory_new("example", GST_TYPE_EXAMPLE, &example_details); + g_return_if_fail(factory != NULL); + + sink_template = gst_padtemplate_new (&sink_factory); + gst_elementfactory_add_padtemplate (factory, sink_template); + + src_template = gst_padtemplate_new (&src_factory); + gst_elementfactory_add_padtemplate (factory, src_template); + + gst_plugin_add_factory (plugin, factory); + + return plugin; +} diff --git a/tests/old/examples/plugins/example.h b/tests/old/examples/plugins/example.h new file mode 100644 index 0000000000..a04f5ba297 --- /dev/null +++ b/tests/old/examples/plugins/example.h @@ -0,0 +1,68 @@ +/* Gnome-Streamer + * Copyright (C) <1999> Erik Walthinsen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#ifndef __GST_EXAMPLE_H__ +#define __GST_EXAMPLE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* Definition of structure storing data for this element. */ +typedef struct _GstExample GstExample; +struct _GstExample { + GstElement element; + + GstPad *sinkpad,*srcpad; + + gint8 active; +}; + +/* Standard definition defining a class for this element. */ +typedef struct _GstExampleClass GstExampleClass; +struct _GstExampleClass { + GstElementClass parent_class; +}; + +/* Standard macros for defining types for this element. */ +#define GST_TYPE_EXAMPLE \ + (gst_example_get_type()) +#define GST_EXAMPLE(obj) \ + (GTK_CHECK_CAST((obj),GST_TYPE_EXAMPLE,GstExample)) +#define GST_EXAMPLE_CLASS(klass) \ + (GTK_CHECK_CLASS_CAST((klass),GST_TYPE_EXAMPLE,GstExample)) +#define GST_IS_EXAMPLE(obj) \ + (GTK_CHECK_TYPE((obj),GST_TYPE_EXAMPLE)) +#define GST_IS_EXAMPLE_CLASS(obj) \ + (GTK_CHECK_CLASS_TYPE((klass),GST_TYPE_EXAMPLE)) + +/* Standard function returning type information. */ +GtkType gst_example_get_type(void); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __GST_EXAMPLE_H__ */