Hi all,<br><br>I'm just running through the plugin writer's guide (<a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/index.html">http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/index.html</a>), specifically the section about building a plugin from generated boilerplate code, and having trouble compiling it.<br>
<br>I have done the following steps:<br>1. Checked out gst-template from cvs<br>2. Generated example filter from template:<br><br>> cd gst-template/gst-plugin/src<br>> ../tools/make_element ExampleFilter<br><br>This created the .c and .h files as expected.<br>
<br>Without making any further changes to the source (since I just want to compile the basic plugin):<br><br>3. added the *.c and *.h to src/Makefile.am, so it looks like:<br><br># plugindir is set in configure<br><br>##############################################################################<br>
# change <a href="http://libgstplugin.la">libgstplugin.la</a> to something more suitable, e.g. <a href="http://libmysomething.la">libmysomething.la</a> #<br>##############################################################################<br>
plugin_LTLIBRARIES = <a href="http://libgstplugin.la">libgstplugin.la</a><br><br>##############################################################################<br># for the next set of variables, rename the prefix if you renamed the .la, #<br>
# e.g. libgstplugin_la_SOURCES => libmysomething_la_SOURCES #<br># libgstplugin_la_CFLAGS => libmysomething_la_CFLAGS #<br># libgstplugin_la_LIBADD => libmysomething_la_LIBADD #<br>
# libgstplugin_la_LDFLAGS => libmysomething_la_LDFLAGS #<br>##############################################################################<br><br># sources used to compile this plug-in<br>libgstplugin_la_SOURCES = gstplugin.c gstexamplefilter.c<br>
<br># flags used to compile this plugin<br># add other _CFLAGS and _LIBS as needed<br>libgstplugin_la_CFLAGS = $(GST_CFLAGS)<br>libgstplugin_la_LIBADD = $(GST_LIBS)<br>libgstplugin_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)<br><br>
# headers we need but don't want installed<br>noinst_HEADERS = gstplugin.h gstexamplefilter.h<br><br>4. Run autogen.sh, all good still.<br>5. make - error compiling gstexamplefilter.c:<br><br>$ make<br>cd . && /bin/bash /space/playpen/gst-template/gst-plugin/missing --run autoheader<br>
touch ./<a href="http://config.h.in">config.h.in</a><br>cd . && /bin/bash ./config.status config.h<br>config.status: creating config.h<br>config.status: config.h is unchanged<br>make all-recursive<br>make[1]: Entering directory `/space/playpen/gst-template/gst-plugin'<br>
Making all in m4<br>make[2]: Entering directory `/space/playpen/gst-template/gst-plugin/m4'<br>make[2]: Nothing to be done for `all'.<br>make[2]: Leaving directory `/space/playpen/gst-template/gst-plugin/m4'<br>
Making all in src<br>make[2]: Entering directory `/space/playpen/gst-template/gst-plugin/src'<br>if /bin/bash ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2 -Wall -Werror -g -O2 -MT libgstplugin_la-gstplugin.lo -MD -MP -MF ".deps/libgstplugin_la-gstplugin.Tpo" \<br>
-c -o libgstplugin_la-gstplugin.lo `test -f 'gstplugin.c' || echo './'`gstplugin.c; \<br> then mv -f ".deps/libgstplugin_la-gstplugin.Tpo" ".deps/libgstplugin_la-gstplugin.Plo"; \<br>
else rm -f ".deps/libgstplugin_la-gstplugin.Tpo"; exit 1; \<br> fi<br> gcc -DHAVE_CONFIG_H -I. -I. -I.. -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2 -Wall -Werror -g -O2 -MT libgstplugin_la-gstplugin.lo -MD -MP -MF .deps/libgstplugin_la-gstplugin.Tpo -c gstplugin.c -fPIC -DPIC -o .libs/libgstplugin_la-gstplugin.o<br>
gcc -DHAVE_CONFIG_H -I. -I. -I.. -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2 -Wall -Werror -g -O2 -MT libgstplugin_la-gstplugin.lo -MD -MP -MF .deps/libgstplugin_la-gstplugin.Tpo -c gstplugin.c -o libgstplugin_la-gstplugin.o >/dev/null 2>&1<br>
if /bin/bash ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2 -Wall -Werror -g -O2 -MT libgstplugin_la-gstexamplefilter.lo -MD -MP -MF ".deps/libgstplugin_la-gstexamplefilter.Tpo" \<br>
-c -o libgstplugin_la-gstexamplefilter.lo `test -f 'gstexamplefilter.c' || echo './'`gstexamplefilter.c; \<br> then mv -f ".deps/libgstplugin_la-gstexamplefilter.Tpo" ".deps/libgstplugin_la-gstexamplefilter.Plo"; \<br>
else rm -f ".deps/libgstplugin_la-gstexamplefilter.Tpo"; exit 1; \<br> fi<br> gcc -DHAVE_CONFIG_H -I. -I. -I.. -pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2 -Wall -Werror -g -O2 -MT libgstplugin_la-gstexamplefilter.lo -MD -MP -MF .deps/libgstplugin_la-gstexamplefilter.Tpo -c gstexamplefilter.c -fPIC -DPIC -o .libs/libgstplugin_la-gstexamplefilter.o<br>
cc1: warnings being treated as errors<br>gstexamplefilter.c: In function 'examplefilter_init':<br>gstexamplefilter.c:254: warning: passing argument 1 of 'gst_element_register' from incompatible pointer type<br>gstexamplefilter.c: At top level:<br>
gstexamplefilter.c:261: warning: initialization from incompatible pointer type<br>make[2]: *** [libgstplugin_la-gstexamplefilter.lo] Error 1<br>make[2]: Leaving directory `/space/playpen/gst-template/gst-plugin/src'<br>
make[1]: *** [all-recursive] Error 1<br>make[1]: Leaving directory `/space/playpen/gst-template/gst-plugin'<br>make: *** [all] Error 2<br><br>Complete listing of gstexamplefilter.c at end of this post.<br><br>"gcc -v" gives:<br>
Using built-in specs.<br>Target: i486-linux-gnu<br>Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu<br>
Thread model: posix<br>gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)<br><br>Is it a problem with my gcc being too recent and being stricter on warnings? Please go easy on me, I haven't any experience with gtk and little with c :-)<br>
<br>Thanks in advance,<br>Jono<br><br>gstexamplefilter.c:<br>/*<br> * GStreamer<br> * Copyright (C) 2005 Thomas Vander Stichele <<a href="mailto:thomas@apestaart.org">thomas@apestaart.org</a>><br> * Copyright (C) 2005 Ronald S. Bultje <<a href="mailto:rbultje@ronald.bitfreak.net">rbultje@ronald.bitfreak.net</a>><br>
* Copyright (C) 2008 Jon Burgess <<<a href="mailto:user@hostname.org">user@hostname.org</a>>><br> * <br> * Permission is hereby granted, free of charge, to any person obtaining a<br> * copy of this software and associated documentation files (the "Software"),<br>
* to deal in the Software without restriction, including without limitation<br> * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br> * and/or sell copies of the Software, and to permit persons to whom the<br>
* Software is furnished to do so, subject to the following conditions:<br> *<br> * The above copyright notice and this permission notice shall be included in<br> * all copies or substantial portions of the Software.<br> *<br>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br>
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
* DEALINGS IN THE SOFTWARE.<br> *<br> * Alternatively, the contents of this file may be used under the<br> * GNU Lesser General Public License Version 2.1 (the "LGPL"), in<br> * which case the following provisions apply instead of the ones<br>
* mentioned above:<br> *<br> * This library is free software; you can redistribute it and/or<br> * modify it under the terms of the GNU Library General Public<br> * License as published by the Free Software Foundation; either<br>
* version 2 of the License, or (at your option) any later version.<br> *<br> * This library is distributed in the hope that it will be useful,<br> * but WITHOUT ANY WARRANTY; without even the implied warranty of<br> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br>
* Library General Public License for more details.<br> *<br> * You should have received a copy of the GNU Library General Public<br> * License along with this library; if not, write to the<br> * Free Software Foundation, Inc., 59 Temple Place - Suite 330,<br>
* Boston, MA 02111-1307, USA.<br> */<br><br>/**<br> * SECTION:element-examplefilter<br> *<br> * FIXME:Describe examplefilter here.<br> *<br> * <refsect2><br> * <title>Example launch line</title><br> * |[<br>
* gst-launch -v -m fakesrc ! examplefilter ! fakesink silent=TRUE<br> * ]|<br> * </refsect2><br> */<br><br>#ifdef HAVE_CONFIG_H<br># include <config.h><br>#endif<br><br>#include <gst/gst.h><br><br>#include "gstexamplefilter.h"<br>
<br>GST_DEBUG_CATEGORY_STATIC (gst_example_filter_debug);<br>#define GST_CAT_DEFAULT gst_example_filter_debug<br><br>/* Filter signals and args */<br>enum<br>{<br> /* FILL ME */<br> LAST_SIGNAL<br>};<br><br>enum<br>{<br>
PROP_0,<br> PROP_SILENT<br>};<br><br>/* the capabilities of the inputs and outputs.<br> *<br> * describe the real formats here.<br> */<br>static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",<br>
GST_PAD_SINK,<br> GST_PAD_ALWAYS,<br> GST_STATIC_CAPS ("ANY")<br> );<br><br>static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",<br> GST_PAD_SRC,<br> GST_PAD_ALWAYS,<br>
GST_STATIC_CAPS ("ANY")<br> );<br><br>GST_BOILERPLATE (GstExampleFilter, gst_example_filter, GstElement,<br> GST_TYPE_ELEMENT);<br><br>static void gst_example_filter_set_property (GObject * object, guint prop_id,<br>
const GValue * value, GParamSpec * pspec);<br>static void gst_example_filter_get_property (GObject * object, guint prop_id,<br> GValue * value, GParamSpec * pspec);<br><br>static gboolean gst_example_filter_set_caps (GstPad * pad, GstCaps * caps);<br>
static GstFlowReturn gst_example_filter_chain (GstPad * pad, GstBuffer * buf);<br><br>/* GObject vmethod implementations */<br><br>static void<br>gst_example_filter_base_init (gpointer gclass)<br>{<br> GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);<br>
<br> gst_element_class_set_details_simple(element_class,<br> "ExampleFilter",<br> "FIXME:Generic",<br> "FIXME:Generic Template Element",<br> "Jon Burgess <<<a href="mailto:user@hostname.org">user@hostname.org</a>>>");<br>
<br> gst_element_class_add_pad_template (element_class,<br> gst_static_pad_template_get (&src_factory));<br> gst_element_class_add_pad_template (element_class,<br> gst_static_pad_template_get (&sink_factory));<br>
}<br><br>/* initialize the examplefilter's class */<br>static void<br>gst_example_filter_class_init (GstExampleFilterClass * klass)<br>{<br> GObjectClass *gobject_class;<br> GstElementClass *gstelement_class;<br><br>
gobject_class = (GObjectClass *) klass;<br> gstelement_class = (GstElementClass *) klass;<br><br> gobject_class->set_property = gst_example_filter_set_property;<br> gobject_class->get_property = gst_example_filter_get_property;<br>
<br> g_object_class_install_property (gobject_class, PROP_SILENT,<br> g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",<br> FALSE, G_PARAM_READWRITE));<br>}<br>
<br>/* initialize the new element<br> * instantiate pads and add them to element<br> * set pad calback functions<br> * initialize instance structure<br> */<br>static void<br>gst_example_filter_init (GstExampleFilter * filter,<br>
GstExampleFilterClass * gclass)<br>{<br> filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");<br> gst_pad_set_setcaps_function (filter->sinkpad,<br> GST_DEBUG_FUNCPTR(gst_example_filter_set_caps));<br>
gst_pad_set_getcaps_function (filter->sinkpad,<br> GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));<br> gst_pad_set_chain_function (filter->sinkpad,<br> GST_DEBUG_FUNCPTR(gst_example_filter_chain));<br>
<br> filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");<br> gst_pad_set_getcaps_function (filter->srcpad,<br> GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));<br>
<br> gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);<br> gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);<br> filter->silent = FALSE;<br>}<br><br>static void<br>gst_example_filter_set_property (GObject * object, guint prop_id,<br>
const GValue * value, GParamSpec * pspec)<br>{<br> GstExampleFilter *filter = GST_EXAMPLEFILTER (object);<br><br> switch (prop_id) {<br> case PROP_SILENT:<br> filter->silent = g_value_get_boolean (value);<br>
break;<br> default:<br> G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);<br> break;<br> }<br>}<br><br>static void<br>gst_example_filter_get_property (GObject * object, guint prop_id,<br> GValue * value, GParamSpec * pspec)<br>
{<br> GstExampleFilter *filter = GST_EXAMPLEFILTER (object);<br><br> switch (prop_id) {<br> case PROP_SILENT:<br> g_value_set_boolean (value, filter->silent);<br> break;<br> default:<br> G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);<br>
break;<br> }<br>}<br><br>/* GstElement vmethod implementations */<br><br>/* this function handles the link with other elements */<br>static gboolean<br>gst_example_filter_set_caps (GstPad * pad, GstCaps * caps)<br>
{<br> GstExampleFilter *filter;<br> GstPad *otherpad;<br><br> filter = GST_EXAMPLEFILTER (gst_pad_get_parent (pad));<br> otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;<br> gst_object_unref (filter);<br>
<br> return gst_pad_set_caps (otherpad, caps);<br>}<br><br>/* chain function<br> * this function does the actual processing<br> */<br>static GstFlowReturn<br>gst_example_filter_chain (GstPad * pad, GstBuffer * buf)<br>{<br>
GstExampleFilter *filter;<br><br> filter = GST_EXAMPLEFILTER (GST_OBJECT_PARENT (pad));<br><br> if (filter->silent == FALSE)<br> g_print ("I'm plugged, therefore I'm in.\n");<br><br> /* just push out the incoming buffer without touching it */<br>
return gst_pad_push (filter->srcpad, buf);<br>}<br><br><br>/* entry point to initialize the plug-in<br> * initialize the plug-in itself<br> * register the element factories and other features<br> */<br>static gboolean<br>
examplefilter_init (GstExampleFilter * examplefilter)<br>{<br> /* debug category for fltering log messages<br> *<br> * exchange the string 'Template examplefilter' with your description<br> */<br> GST_DEBUG_CATEGORY_INIT (gst_example_filter_debug, "examplefilter",<br>
0, "Template examplefilter");<br><br> return gst_element_register (examplefilter, "examplefilter", GST_RANK_NONE,<br> GST_TYPE_EXAMPLEFILTER);<br>}<br><br>/* gstreamer looks for this structure to register examplefilters<br>
*<br> * exchange the string 'Template examplefilter' with your examplefilter description<br> */<br>GST_PLUGIN_DEFINE (<br> GST_VERSION_MAJOR,<br> GST_VERSION_MINOR,<br> "examplefilter",<br> "Template examplefilter",<br>
examplefilter_init,<br> VERSION,<br> "LGPL",<br> "GStreamer",<br> "<a href="http://gstreamer.net/">http://gstreamer.net/</a>"<br>)<br><br><br>gstexamplefilter.h:<br>/*<br> * GStreamer<br>
* Copyright (C) 2005 Thomas Vander Stichele <<a href="mailto:thomas@apestaart.org">thomas@apestaart.org</a>><br> * Copyright (C) 2005 Ronald S. Bultje <<a href="mailto:rbultje@ronald.bitfreak.net">rbultje@ronald.bitfreak.net</a>><br>
* Copyright (C) 2008 Jon Burgess <<<a href="mailto:user@hostname.org">user@hostname.org</a>>><br> * <br> * Permission is hereby granted, free of charge, to any person obtaining a<br> * copy of this software and associated documentation files (the "Software"),<br>
* to deal in the Software without restriction, including without limitation<br> * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br> * and/or sell copies of the Software, and to permit persons to whom the<br>
* Software is furnished to do so, subject to the following conditions:<br> *<br> * The above copyright notice and this permission notice shall be included in<br> * all copies or substantial portions of the Software.<br> *<br>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br>
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
* DEALINGS IN THE SOFTWARE.<br> *<br> * Alternatively, the contents of this file may be used under the<br> * GNU Lesser General Public License Version 2.1 (the "LGPL"), in<br> * which case the following provisions apply instead of the ones<br>
* mentioned above:<br> *<br> * This library is free software; you can redistribute it and/or<br> * modify it under the terms of the GNU Library General Public<br> * License as published by the Free Software Foundation; either<br>
* version 2 of the License, or (at your option) any later version.<br> *<br> * This library is distributed in the hope that it will be useful,<br> * but WITHOUT ANY WARRANTY; without even the implied warranty of<br> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br>
* Library General Public License for more details.<br> *<br> * You should have received a copy of the GNU Library General Public<br> * License along with this library; if not, write to the<br> * Free Software Foundation, Inc., 59 Temple Place - Suite 330,<br>
* Boston, MA 02111-1307, USA.<br> */<br><br>#ifndef __GST_EXAMPLEFILTER_H__<br>#define __GST_EXAMPLEFILTER_H__<br><br>#include <gst/gst.h><br><br>G_BEGIN_DECLS<br><br>/* #defines don't like whitespacey bits */<br>
#define GST_TYPE_EXAMPLEFILTER \<br> (gst_example_filter_get_type())<br>#define GST_EXAMPLEFILTER(obj) \<br> (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_EXAMPLEFILTER,GstExampleFilter))<br>#define GST_EXAMPLEFILTER_CLASS(klass) \<br>
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_EXAMPLEFILTER,GstExampleFilterClass))<br>#define GST_IS_EXAMPLEFILTER(obj) \<br> (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_EXAMPLEFILTER))<br>#define GST_IS_EXAMPLEFILTER_CLASS(klass) \<br>
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_EXAMPLEFILTER))<br><br>typedef struct _GstExampleFilter GstExampleFilter;<br>typedef struct _GstExampleFilterClass GstExampleFilterClass;<br><br>struct _GstExampleFilter<br>
{<br> GstElement element;<br><br> GstPad *sinkpad, *srcpad;<br><br> gboolean silent;<br>};<br><br>struct _GstExampleFilterClass <br>{<br> GstElementClass parent_class;<br>};<br><br>GType gst_example_filter_get_type (void);<br>
<br>G_END_DECLS<br><br>#endif /* __GST_EXAMPLEFILTER_H__ */<br><br><br>