summaryrefslogtreecommitdiff
path: root/gst-plugin
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2002-08-06 08:55:34 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2002-08-06 08:55:34 +0000
commit2b389da26287af4cc79a1a3974a3c66ec46ff5a7 (patch)
tree879cc632647f3be8983e1cb0dfed91e432b682af /gst-plugin
template code plugins don't work yet, I messed something up and I'm still looking for it
Original commit message from CVS: template code plugins don't work yet, I messed something up and I'm still looking for it
Diffstat (limited to 'gst-plugin')
-rw-r--r--gst-plugin/AUTHORS1
-rw-r--r--gst-plugin/ChangeLog3
-rw-r--r--gst-plugin/Makefile.am3
-rw-r--r--gst-plugin/NEWS1
-rw-r--r--gst-plugin/README12
-rwxr-xr-xgst-plugin/autogen.sh14
-rw-r--r--gst-plugin/configure.ac55
-rw-r--r--gst-plugin/src/Makefile.am16
-rw-r--r--gst-plugin/src/gstplugin.c262
-rw-r--r--gst-plugin/src/gstplugin.h47
10 files changed, 414 insertions, 0 deletions
diff --git a/gst-plugin/AUTHORS b/gst-plugin/AUTHORS
new file mode 100644
index 0000000..1bb7449
--- /dev/null
+++ b/gst-plugin/AUTHORS
@@ -0,0 +1 @@
+Thomas Vander Stichele <thomas@apestaart.org>
diff --git a/gst-plugin/ChangeLog b/gst-plugin/ChangeLog
new file mode 100644
index 0000000..02d2786
--- /dev/null
+++ b/gst-plugin/ChangeLog
@@ -0,0 +1,3 @@
+2002-07-17 Thomas Vander Stichele <thomas@apestaart.org>
+
+ * initial creation on a flight to New York
diff --git a/gst-plugin/Makefile.am b/gst-plugin/Makefile.am
new file mode 100644
index 0000000..43340e8
--- /dev/null
+++ b/gst-plugin/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS=src
+
+EXTRA_DIST=depcomp
diff --git a/gst-plugin/NEWS b/gst-plugin/NEWS
new file mode 100644
index 0000000..3474a99
--- /dev/null
+++ b/gst-plugin/NEWS
@@ -0,0 +1 @@
+Nothing much yet.
diff --git a/gst-plugin/README b/gst-plugin/README
new file mode 100644
index 0000000..e800f09
--- /dev/null
+++ b/gst-plugin/README
@@ -0,0 +1,12 @@
+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.
diff --git a/gst-plugin/autogen.sh b/gst-plugin/autogen.sh
new file mode 100755
index 0000000..4cc32bc
--- /dev/null
+++ b/gst-plugin/autogen.sh
@@ -0,0 +1,14 @@
+#!/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
+
diff --git a/gst-plugin/configure.ac b/gst-plugin/configure.ac
new file mode 100644
index 0000000..0130e7e
--- /dev/null
+++ b/gst-plugin/configure.ac
@@ -0,0 +1,55 @@
+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)
+
diff --git a/gst-plugin/src/Makefile.am b/gst-plugin/src/Makefile.am
new file mode 100644
index 0000000..09bcc8b
--- /dev/null
+++ b/gst-plugin/src/Makefile.am
@@ -0,0 +1,16 @@
+# 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
diff --git a/gst-plugin/src/gstplugin.c b/gst-plugin/src/gstplugin.c
new file mode 100644
index 0000000..934911c
--- /dev/null
+++ b/gst-plugin/src/gstplugin.c
@@ -0,0 +1,262 @@
+/*
+ *
+ * GStreamer
+ * Copyright (C) 1999-2001 Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * 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 <thomas@apestaart.org>",
+ "(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
+};
diff --git a/gst-plugin/src/gstplugin.h b/gst-plugin/src/gstplugin.h
new file mode 100644
index 0000000..e79d985
--- /dev/null
+++ b/gst-plugin/src/gstplugin.h
@@ -0,0 +1,47 @@
+/*
+ * 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__ */