From: Thomas V. S. <tho...@us...> - 2002-08-06 08:55:48
|
CVS Root: /cvsroot/gstreamer Module: gst-template Changes by: thomasvs Date: Tue Aug 06 2002 01:55:46 PDT Log message: template code plugins don't work yet, I messed something up and I'm still looking for it Added files: . : README gst-app : AUTHORS ChangeLog Makefile.am NEWS README autogen.sh configure.ac gst-app/src : Makefile.am gst-app.h load.c load.h main.c gst-plugin : AUTHORS ChangeLog Makefile.am NEWS README autogen.sh configure.ac gst-plugin/src : Makefile.am gstplugin.c gstplugin.h Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/README?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/AUTHORS?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/ChangeLog?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/Makefile.am?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/NEWS?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/README?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/autogen.sh?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/configure.ac?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/src/Makefile.am?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/src/gst-app.h?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/src/load.c?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/src/load.h?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-app/src/main.c?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-plugin/AUTHORS?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-plugin/ChangeLog?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-plugin/Makefile.am?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-plugin/NEWS?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-plugin/README?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-plugin/autogen.sh?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-plugin/configure.ac?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-plugin/src/Makefile.am?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-plugin/src/gstplugin.c?rev=1.1&content-type=text/vnd.viewcvs-markup http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-template/gst-plugin/src/gstplugin.h?rev=1.1&content-type=text/vnd.viewcvs-markup ====Begin Diffs==== --- NEW FILE: README --- This CVS module contains template code for possible GStreamer projects. gst-app basic autotools layout for writing a GStreamer-based application gst-plugin basic autotools layout for writing a GStreamer plug-in --- NEW FILE: AUTHORS --- Thomas Vander Stichele <th...@ap...> --- NEW FILE: ChangeLog --- 2002-07-17 Thomas Vander Stichele <th...@ap...> * initial creation on a flight to New York --- NEW FILE: Makefile.am --- SUBDIRS=src EXTRA_DIST=depcomp --- NEW FILE: NEWS --- Nothing much yet. --- NEW FILE: README --- gst-app is a template for writing your own GStreamer-based app. The code is deliberately kept simple so that you quickly understand the basics of how to set up autotools and your source tree. This template demonstrates : - what to do in autogen.sh - how to setup configure.ac (your package name and version, GStreamer flags) - how to setup your source dir - main () and main header - supporting source code - Makefile.am The template performs one simple function : loading a pipeline from xml and start to iterate it. Try saving a pipeline from gst-editor, it will play with this sample program. More features might get added to this template later on. --- NEW FILE: autogen.sh --- #!/bin/sh if test -z $AUTOCONF; then export AUTOCONF=autoconf-2.53; fi if test -z $AUTOMAKE; then export AUTOMAKE=automake-1.5 export ACLOCAL=aclocal-1.5 fi set -x $ACLOCAL && libtoolize --force && \ # autoheader $AUTOCONF && \ $AUTOMAKE -a && \ ./configure --- NEW FILE: configure.ac --- AC_INIT dnl Fill in your package name and version here PACKAGE=gst-app VERSION=0.1.0 dnl these AC_DEFINE_UNQUOTED's are necessary for make dist to work AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE") AC_DEFINE_UNQUOTED(VERSION, "$VERSION") AC_DEFINE_UNQUOTED(RELEASE, "$RELEASE") AC_SUBST(PACKAGE) AC_SUBST(VERSION) AC_SUBST(RELEASE) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) AC_PROG_CC AC_PROG_LIBTOOL dnl Check for pkgconfig first AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no) dnl Give error and exit if we don't have pkgconfig if test "x$HAVE_PKGCONFIG" = "xno"; then AC_MSG_ERROR(you need to have pkgconfig installed !) fi dnl Now we're ready to ask for gstreamer libs and cflags dnl And we can also ask for the right version of gstreamer PKG_CHECK_MODULES(GST, gstreamer >= 0.4.0, HAVE_GST=yes, HAVE_GST=no) dnl Give error and exit if we don't have gstreamer if test "x$HAVE_GST" = "xno"; then AC_MSG_ERROR(you need gstreamer development packages installed !) fi dnl make GST_CFLAGS and GST_LIBS available AC_SUBST(GST_CFLAGS) AC_SUBST(GST_LIBS) dnl If we need them, we can also use the plugin libraries PKG_CHECK_MODULES(GST_LIBS, gstreamer-libs >= 0.4.0, HAVE_GST_LIBS=yes, HAVE_GST_LIBS=no) dnl Give a warning if we don't have gstreamer libs if test "x$HAVE_GST_LIBS" = "xno"; then AC_MSG_NOTICE(no GStreamer plugin libs found) fi dnl make GST_LIBS_CFLAGS and GST_LIBS_LIBS available AC_SUBST(GST_LIBS_CFLAGS) AC_SUBST(GST_LIBS_LIBS) AC_OUTPUT(Makefile src/Makefile) --- NEW FILE: Makefile.am --- # name of your binary bin_PROGRAMS = gst-app # list of source files # the prefix is the name of the binary gst_app_SOURCES = main.c load.c # list of headers we're not going to install noinst_HEADERS = gst-app.h load.h # our CFLAGS and LDFLAGS used for compiling and linking # make sure you prefix these with the name of your binary gst_app_CFLAGS = $(GST_CFLAGS) gst_app_LDFLAGS = $(GST_LIBS) --- NEW FILE: gst-app.h --- #include "load.h" --- NEW FILE: load.c --- /* * GStreamer gst-app template * load.c : load a pipeline from disk */ #include <gst/gst.h> /* * load an xml pipeline description and parse it * Returns: the top-level element, or NULL if unable to parse */ GstElement * gst_app_pipeline_load (const gchar *filename) { GstXML *xml; GList *l; xml = gst_xml_new (); if (gst_xml_parse_file (xml, filename, NULL) != TRUE) { g_warning ("Error loading pipeline from file '%s'\n", filename); return NULL; } l = gst_xml_get_topelements (xml); if (l == NULL) { g_warning ("No toplevel element in file '%s'\n", filename); return NULL; } if (l->next != NULL) { g_warning ("More than one toplevel element in file '%s'\n", filename); return NULL; } return GST_ELEMENT (l->data); } --- NEW FILE: load.h --- /* * GStreamer gst-app template * load.h : load a pipeline from disk */ #include <gst/gst.h> GstElement * gst_app_pipeline_load (const gchar *filename); --- NEW FILE: main.c --- #include "gst-app.h" int main (int argc, char *argv[]) { gchar *filename; GstElement *pipeline; gst_init (&argc, &argv); if (argc <= 1) g_error ("Please supply an xml file describing a pipeline !\n"); filename = g_strdup_printf ("%s", argv[1]); pipeline = gst_app_pipeline_load (filename); if (pipeline == NULL) { g_warning ("Could not get a usable pipeline from file '%s'\n", filename); return 1; } gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))) g_print ("+"); g_print ("\n"); return 0; } --- NEW FILE: AUTHORS --- Thomas Vander Stichele <th...@ap...> --- NEW FILE: ChangeLog --- 2002-07-17 Thomas Vander Stichele <th...@ap...> * initial creation on a flight to New York --- NEW FILE: Makefile.am --- SUBDIRS=src EXTRA_DIST=depcomp --- NEW FILE: NEWS --- Nothing much yet. --- NEW FILE: README --- gst-plugin is a template for writing your own GStreamer plug-in. The code is deliberately kept simple so that you quickly understand the basics of how to set up autotools and your source tree. This template demonstrates : - what to do in autogen.sh - how to setup configure.ac (your package name and version, GStreamer flags) - how to setup your source dir - what to put in Makefile.am More features might get added to this template later on. --- NEW FILE: autogen.sh --- #!/bin/sh if test -z $AUTOCONF; then export AUTOCONF=autoconf-2.53; fi if test -z $AUTOMAKE; then export AUTOMAKE=automake-1.5 export ACLOCAL=aclocal-1.5 fi set -x $ACLOCAL && libtoolize --force && \ # autoheader $AUTOCONF && \ $AUTOMAKE -a && \ ./configure --- NEW FILE: configure.ac --- AC_INIT dnl Fill in your package name and version here PACKAGE=gst-plugin VERSION=0.1.0 dnl these AC_DEFINE_UNQUOTED's are necessary for make dist to work AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE") AC_DEFINE_UNQUOTED(VERSION, "$VERSION") AC_DEFINE_UNQUOTED(RELEASE, "$RELEASE") AC_SUBST(PACKAGE) AC_SUBST(VERSION) AC_SUBST(RELEASE) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) AC_PROG_CC AC_PROG_LIBTOOL dnl Check for pkgconfig first AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no) dnl Give error and exit if we don't have pkgconfig if test "x$HAVE_PKGCONFIG" = "xno"; then AC_MSG_ERROR(you need to have pkgconfig installed !) fi dnl Now we're ready to ask for gstreamer libs and cflags dnl And we can also ask for the right version of gstreamer PKG_CHECK_MODULES(GST, gstreamer >= 0.4.0, HAVE_GST=yes, HAVE_GST=no) dnl Give error and exit if we don't have gstreamer if test "x$HAVE_GST" = "xno"; then AC_MSG_ERROR(you need gstreamer development packages installed !) fi dnl make GST_CFLAGS and GST_LIBS available AC_SUBST(GST_CFLAGS) AC_SUBST(GST_LIBS) dnl If we need them, we can also use the plugin libraries PKG_CHECK_MODULES(GST_LIBS, gstreamer-libs >= 0.4.0, HAVE_GST_LIBS=yes, HAVE_GST_LIBS=no) dnl Give a warning if we don't have gstreamer libs if test "x$HAVE_GST_LIBS" = "xno"; then AC_MSG_NOTICE(no GStreamer plugin libs found) fi dnl make GST_LIBS_CFLAGS and GST_LIBS_LIBS available AC_SUBST(GST_LIBS_CFLAGS) AC_SUBST(GST_LIBS_LIBS) AC_OUTPUT(Makefile src/Makefile) --- NEW FILE: Makefile.am --- # location where plug-in will be installed plugindir= $(libdir)/gst # change libgstplugin.la to something more suitable plugin_LTLIBRARIES = libgstplugin.la # sources used to compile this plug-in libgstvolume_la_SOURCES = gstplugin.c # flags used to compile this plugin # we use the GST_LIBS flags because we might be using plug-in libs libgstvolume_la_CFLAGS = $(GST_LIBS_CFLAGS) libgstvolume_la_LDFLAGS = $(GST_LIBS_LDFLAGS) # headers we need but don't want installed noinst_HEADERS = gstplugin.h --- NEW FILE: gstplugin.c --- /* * * GStreamer * Copyright (C) 1999-2001 Erik Walthinsen <om...@cs...> * * 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 <string.h> #include <gst/gst.h> #include <gst/audio/audio.h> #include <gst/control/control.h> #include "gstplugin.h" static GstElementDetails plugin_details = { "Plugin", "Generic/Plugin", "Generic Template Plugin", VERSION, "Thomas Vander Stichele <th...@ap...>", "(C) 2002" }; /* Filter signals and args */ enum { /* FILL ME */ LAST_SIGNAL }; enum { ARG_0, ARG_SILENT, }; GST_PAD_TEMPLATE_FACTORY (plugin_sink_factory, "sink", GST_PAD_SINK, GST_PAD_ALWAYS, NULL /* no caps */ ); GST_PAD_TEMPLATE_FACTORY (plugin_src_factory, "src", GST_PAD_SRC, GST_PAD_ALWAYS, NULL /* no caps */ ); static void plugin_class_init (GstPluginClass *klass); static void plugin_init (GstPlugin *filter); static void plugin_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void plugin_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void plugin_update_plugin (const GValue *value, gpointer data); static void plugin_update_mute (const GValue *value, gpointer data); static void plugin_chain (GstPad *pad, GstBuffer *buf); static GstElementClass *parent_class = NULL; /* this function handles the connection with other plug-ins */ static GstPadConnectReturn plugin_connect (GstPad *pad, GstCaps *caps) { GstPlugin *filter; GstPad *otherpad; filter = GST_PLUGIN (gst_pad_get_parent (pad)); g_return_val_if_fail (filter != NULL, GST_PAD_CONNECT_REFUSED); g_return_val_if_fail (GST_IS_PLUGIN (filter), GST_PAD_CONNECT_REFUSED); otherpad = (pad == filter->srcpad ? filter->sinkpad : filter->srcpad); if (GST_CAPS_IS_FIXED (caps)) { /* caps are not fixed, so try to connect on the other side and see if * that works */ if (!gst_pad_try_set_caps (otherpad, caps)) return GST_PAD_CONNECT_REFUSED; /* caps on other side were accepted, so we're ok */ return GST_PAD_CONNECT_OK; } /* not enough information yet, delay negotation */ return GST_PAD_CONNECT_DELAYED; } GType gst_plugin_get_type (void) { static GType plugin_type = 0; if (!plugin_type) { static const GTypeInfo plugin_info = { sizeof (GstPluginClass), NULL, NULL, (GClassInitFunc) plugin_class_init, NULL, NULL, sizeof (GstPlugin), 0, (GInstanceInitFunc) plugin_init, }; plugin_type = g_type_register_static (GST_TYPE_ELEMENT, "GstPlugin", &plugin_info, 0); } return plugin_type; } static void plugin_class_init (GstPluginClass *klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; gobject_class = (GObjectClass*) klass; gstelement_class = (GstElementClass*) klass; parent_class = g_type_class_ref (GST_TYPE_ELEMENT); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MUTE, g_param_spec_boolean ("silent", "silent", "silent", FALSE, G_PARAM_READWRITE)); gobject_class->set_property = plugin_set_property; gobject_class->get_property = plugin_get_property; } /* initialize the new plug-in * instantiate pads and add them to plug-in * set functions * initialize structure */ static void plugin_init (GstPlugin *filter) { filter->sinkpad = gst_pad_new_from_template (plugin_sink_factory (), "sink"); gst_pad_set_connect_function (filter->sinkpad, plugin_connect); filter->srcpad = gst_pad_new_from_template (plugin_src_factory (), "src"); gst_pad_set_connect_function (filter->srcpad, plugin_connect); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); gst_pad_set_chain_function (filter->sinkpad, plugin_chain); filter->silent = FALSE; } /* chain function * this function does the actual processing */ static void plugin_chain (GstPad *pad, GstBuffer *buf) { GstPlugin *filter; GstBuffer *out_buf; gfloat *data; gint i, num_samples; g_return_if_fail (GST_IS_PAD (pad)); g_return_if_fail (buf != NULL); filter = GST_PLUGIN (GST_OBJECT_PARENT (pad)); g_return_if_fail (GST_IS_PLUGIN (filter)); if (filter->silent == FALSE) g_print ("I'm plugged, therefore I'm in.\n"); /* just push out the incoming buffer without touching it */ gst_pad_push (filter->srcpad, buf); } static void plugin_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GstPlugin *filter; g_return_if_fail (GST_IS_PLUGIN (object)); filter = GST_PLUGIN (object); switch (prop_id) { case ARG_SILENT: filter->silent = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void plugin_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { GstPlugin *filter; g_return_if_fail (GST_IS_PLUGIN (object)); filter = GST_PLUGIN (object); switch (prop_id) { case ARG_SILENT: g_value_set_boolean (value, filter->silent); default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } /* initialize the plugin * register the element factories and pad templates * register the features */ static gboolean plugin_init (GModule *module, GstPlugin *plugin) { GstElementFactory *factory; factory = gst_element_factory_new ("plugin", GST_TYPE_PLUGIN, &plugin_details); g_return_val_if_fail (factory != NULL, FALSE); gst_element_factory_add_pad_template (factory, plugin_src_factory ()); gst_element_factory_add_pad_template (factory, plugin_sink_factory ()); gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); /* plugin initialisation succeeded */ return TRUE; } GstPluginDesc plugin_desc = { GST_VERSION_MAJOR, GST_VERSION_MINOR, "plugin", plugin_init }; --- NEW FILE: gstplugin.h --- /* * gstplugin.h: sample header file for plug-in */ #ifndef __GST_PLUGIN_H__ #define __GST_PLUGIN_H__ #include <gst/gst.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #define GST_TYPE_PLUGIN \ (gst_plugin_get_type()) #define GST_PLUGIN(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLUGIN,GstPlugin)) #define GST_PLUGIN_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ULAW,GstPlugin)) #define GST_IS_PLUGIN(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLUGIN)) #define GST_IS_PLUGIN_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLUGIN)) typedef struct _GstPlugin GstPlugin; typedef struct _GstPluginClass GstPluginClass; struct _GstPlugin { GstElement element; GstPad *sinkpad, *srcpad; gboolean silent; }; struct _GstPluginClass { GstElementClass parent_class; }; GType gst_plugin_get_type(void); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __GST_PLUGIN_H__ */ |