summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.gitmodules3
-rw-r--r--README49
-rw-r--r--README.md77
-rw-r--r--gst-app/.gitignore19
-rw-r--r--gst-app/Makefile.am3
-rw-r--r--gst-app/NEWS1
-rw-r--r--gst-app/README18
-rwxr-xr-xgst-app/autogen.sh18
-rw-r--r--gst-app/configure.ac94
-rw-r--r--gst-app/meson.build6
-rw-r--r--gst-app/src/Makefile.am14
-rw-r--r--gst-app/src/main.c5
-rw-r--r--gst-app/src/play.c6
-rw-r--r--gst-plugin/.gitignore14
-rw-r--r--gst-plugin/Makefile.am3
-rw-r--r--gst-plugin/NEWS1
-rw-r--r--gst-plugin/README34
-rwxr-xr-xgst-plugin/autogen.sh18
-rw-r--r--gst-plugin/configure.ac87
-rw-r--r--gst-plugin/meson.build52
-rw-r--r--gst-plugin/src/Makefile.am26
-rw-r--r--gst-plugin/src/gstaudiofilter.c252
-rw-r--r--gst-plugin/src/gstplugin.c129
-rw-r--r--gst-plugin/src/gstplugin.h25
-rw-r--r--gst-plugin/src/gsttransform.c125
-rw-r--r--gst-plugin/src/gsttransform.h23
-rwxr-xr-xgst-plugin/tools/make_element14
-rw-r--r--meson.build17
29 files changed, 436 insertions, 699 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1677b58
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+build*
+*~
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 1ba590b..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "common"]
- path = common
- url = git://anongit.freedesktop.org/gstreamer/common
diff --git a/README b/README
deleted file mode 100644
index 44dc857..0000000
--- a/README
+++ /dev/null
@@ -1,49 +0,0 @@
-This git module contains template code for possible GStreamer projects.
-
-gst-app
- basic autotools layout for writing a GStreamer-based application.
-
-gst-plugin
- basic autotools layout and basic filter code for writing a
- GStreamer plug-in.
-
-This code is provided under a MIT license [1], which basically means "do
-with it as you wish, but don't blame us if it doesn't work". You can use
-this code for any project as you wish, under any license as you wish. We
-recommend the use of the LGPL [2] license for applications and plugins,
-given the minefield of patents the multimedia is nowadays. See our website
-for details [3].
-
-Build each module like this:
-
- cd gst-plugin
- ./autogen.sh
- make
-
-Modify gst-plugin/src/Makefile.am to add or remove source files to build or
-add additional dependencies or compiler flags or change the name of the
-plugin file to be installed. Run ./autoregen.sh if changes don't take effect
-automatically on 'make'.
-
-Modify gst-plugin/configure.ac to check for additional library dependencies
-or other features needed by your plugin. Run ./autoregen.sh if changes don't
-take effect automatically on 'make'.
-
-Once the plugin is built you can either install it with 'sudo make install'
-(however, this will by default go into the /usr/local prefix where it won't
-be picked up by a GStreamer installed from packages, so you would need to
-set the GST_PLUGIN_PATH environment variable to include or point to
-/usr/local/lib/gstreamer-0.10/ for your plugin to be found by a from-package
-GStreamer). Alternatively, you will find your plugin binary in
-gst-plugins/src/.libs/ as libgstplugin.so or similar (the extension may vary),
-so you can also set the GST_PLUGIN_PATH environmen variable to the
-gst-plugins/src/.libs/ directory (best to specify an absolute path though).
-
-You can also check if it has been built correctly with:
-
- gst-inspect-0.10 gst-plugins/src/.libs/libgstplugin.so
-
-
-[1] http://www.opensource.org/licenses/mit-license.php or COPYING.MIT
-[2] http://www.opensource.org/licenses/lgpl-license.php or COPYING.LIB
-[3] http://gstreamer.freedesktop.org/documentation/licensing.html
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4a30fd8
--- /dev/null
+++ b/README.md
@@ -0,0 +1,77 @@
+# GStreamer template repository
+
+This git module contains template code for possible GStreamer projects.
+
+* gst-app :
+ basic meson-based layout for writing a GStreamer-based application.
+
+* gst-plugin :
+ basic meson-based layout and basic filter code for writing a GStreamer plug-in.
+
+## License
+
+This code is provided under a MIT license [MIT], which basically means "do
+with it as you wish, but don't blame us if it doesn't work". You can use
+this code for any project as you wish, under any license as you wish. We
+recommend the use of the LGPL [LGPL] license for applications and plugins,
+given the minefield of patents the multimedia is nowadays. See our website
+for details [Licensing].
+
+## Usage
+
+Configure and build all examples (application and plugins) as such:
+
+ meson builddir
+ ninja -C builddir
+
+See <https://mesonbuild.com/Quick-guide.html> on how to install the Meson
+build system and ninja.
+
+Modify `gst-plugin/meson.build` to add or remove source files to build or
+add additional dependencies or compiler flags or change the name of the
+plugin file to be installed.
+
+Modify `meson.build` to check for additional library dependencies
+or other features needed by your plugin.
+
+Once the plugin is built you can either install system-wide it with `sudo ninja
+-C builddir install` (however, this will by default go into the `/usr/local`
+prefix where it won't be picked up by a `GStreamer` installed from packages, so
+you would need to set the `GST_PLUGIN_PATH` environment variable to include or
+point to `/usr/local/lib/gstreamer-1.0/` for your plugin to be found by a
+from-package `GStreamer`).
+
+Alternatively, you will find your plugin binary in `builddir/gst-plugins/src/`
+as `libgstplugin.so` or similar (the extension may vary), so you can also set
+the `GST_PLUGIN_PATH` environment variable to the `builddir/gst-plugins/src/`
+directory (best to specify an absolute path though).
+
+You can also check if it has been built correctly with:
+
+ gst-inspect-1.0 builddir/gst-plugins/src/libgstplugin.so
+
+## Auto-generating your own plugin
+
+You will find a helper script in `gst-plugins/tools/make_element` to generate
+the source/header files for a new plugin.
+
+To create sources for `myfilter` based on the `gsttransform` template run:
+
+``` shell
+cd src;
+../tools/make_element myfilter gsttransform
+```
+
+This will create `gstmyfilter.c` and `gstmyfilter.h`. Open them in an editor and
+start editing. There are several occurances of the string `template`, update
+those with real values. The plugin will be called `myfilter` and it will have
+one element called `myfilter` too. Also look for `FIXME:` markers that point you
+to places where you need to edit the code.
+
+You can then add your sources files to `gst-plugins/meson.build` and re-run
+ninja to have your plugin built.
+
+
+[MIT]: http://www.opensource.org/licenses/mit-license.php or COPYING.MIT
+[LGPL]: http://www.opensource.org/licenses/lgpl-license.php or COPYING.LIB
+[Licensing]: https://gstreamer.freedesktop.org/documentation/application-development/appendix/licensing.html
diff --git a/gst-app/.gitignore b/gst-app/.gitignore
deleted file mode 100644
index 6fa734f..0000000
--- a/gst-app/.gitignore
+++ /dev/null
@@ -1,19 +0,0 @@
-aclocal.m4
-autom4te.cache
-autoregen.sh
-config.*
-configure
-libtool
-INSTALL
-Makefile.in
-depcomp
-install-sh
-ltmain.sh
-missing
-stamp-*
-compile
-my-app-*.tar.*
-*~
-
-src/gst-app
-
diff --git a/gst-app/Makefile.am b/gst-app/Makefile.am
deleted file mode 100644
index acdcc2a..0000000
--- a/gst-app/Makefile.am
+++ /dev/null
@@ -1,3 +0,0 @@
-SUBDIRS=src
-
-EXTRA_DIST=autogen.sh
diff --git a/gst-app/NEWS b/gst-app/NEWS
deleted file mode 100644
index 3474a99..0000000
--- a/gst-app/NEWS
+++ /dev/null
@@ -1 +0,0 @@
-Nothing much yet.
diff --git a/gst-app/README b/gst-app/README
deleted file mode 100644
index 77751cd..0000000
--- a/gst-app/README
+++ /dev/null
@@ -1,18 +0,0 @@
-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.
diff --git a/gst-app/autogen.sh b/gst-app/autogen.sh
deleted file mode 100755
index 9df38d3..0000000
--- a/gst-app/autogen.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-# you can either set the environment variables AUTOCONF, AUTOHEADER, AUTOMAKE,
-# ACLOCAL, AUTOPOINT and/or LIBTOOLIZE to the right versions, or leave them
-# unset and get the defaults
-
-autoreconf --verbose --force --install --make || {
- echo 'autogen.sh failed';
- exit 1;
-}
-
-./configure || {
- echo 'configure failed';
- exit 1;
-}
-
-echo
-echo "Now type 'make' to compile this module."
-echo
diff --git a/gst-app/configure.ac b/gst-app/configure.ac
deleted file mode 100644
index a172c18..0000000
--- a/gst-app/configure.ac
+++ /dev/null
@@ -1,94 +0,0 @@
-dnl required version of autoconf
-AC_PREREQ([2.53])
-
-dnl TODO: fill in your package name and package version here
-AC_INIT([my-app],[0.1.1])
-
-dnl required version of gstreamer and gst-plugins-base
-GST_REQUIRED=0.10.16
-
-AC_CONFIG_SRCDIR([src/main.c])
-AC_CONFIG_HEADERS([config.h])
-
-dnl required version of automake
-AM_INIT_AUTOMAKE([1.10])
-
-dnl enable mainainer mode by default
-AM_MAINTAINER_MODE([enable])
-
-dnl check for tools (compiler etc.)
-AM_PROG_CC_C_O
-
-dnl required version of libtool
-LT_PREREQ([2.2.6])
-LT_INIT
-
-dnl error out if we can't find pkg-config
-AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, [ ], [
- AC_MSG_ERROR([You need to have pkg-config installed or set the PATH.])
-])
-
-dnl =======================================================================
-dnl Check for the required version of GStreamer core (and gst-plugins-base)
-dnl
-dnl This will export GST_CFLAGS and GST_LIBS variables for use in Makefile.am
-dnl
-dnl If you need libraries from gst-plugins-base here, also add:
-dnl for libgstaudio-0.10: gstreamer-audio-0.10 >= $GST_REQUIRED
-dnl for libgstvideo-0.10: gstreamer-video-0.10 >= $GST_REQUIRED
-dnl for libgsttag-0.10: gstreamer-tag-0.10 >= $GST_REQUIRED
-dnl for libgstpbutils-0.10: gstreamer-pbutils-0.10 >= $GST_REQUIRED
-dnl for libgstfft-0.10: gstreamer-fft-0.10 >= $GST_REQUIRED
-dnl for libgstinterfaces-0.10: gstreamer-interfaces-0.10 >= $GST_REQUIRED
-dnl for libgstrtp-0.10: gstreamer-rtp-0.10 >= $GST_REQUIRED
-dnl for libgstrtsp-0.10: gstreamer-rtsp-0.10 >= $GST_REQUIRED
-dnl etc.
-dnl =======================================================================
-
-PKG_CHECK_MODULES(GST, [
- gstreamer-0.10 >= $GST_REQUIRED
- gstreamer-base-0.10 >= $GST_REQUIRED
- gstreamer-controller-0.10 >= $GST_REQUIRED
- ], [
- AC_SUBST(GST_CFLAGS)
- AC_SUBST(GST_LIBS)
- ], [
- AC_MSG_ERROR([
- Can't find the following GStreamer development packages:
-
- gstreamer-0.10 >= $GST_REQUIRED
- gstreamer-base-0.10 >= $GST_REQUIRED
- gstreamer-controller-0.10 >= $GST_REQUIRED
-
- Please make sure you have the necessary GStreamer-0.10
- development headers installed.
-
- On debian/Ubuntu systems you will probably need to install the
- 'libgstreamer0.10-dev' and 'libgstreamer-plugins-base0.10-dev' packages.
-
- On RPM-based systems you will probably need to install the
- 'gstreamer-devel-0.10' package.
- ])
-])
-
-dnl check if compiler understands -Wall (if yes, add -Wall to GST_CFLAGS)
-AC_MSG_CHECKING([to see if compiler understands -Wall])
-save_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wall"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ], [ ])], [
- GST_CFLAGS="$GST_CFLAGS -Wall"
- AC_MSG_RESULT([yes])
-], [
- AC_MSG_RESULT([no])
-])
-
-dnl =======================================================================
-dnl Finally, create Makefiles in all directories
-dnl =======================================================================
-
-AC_CONFIG_FILES([
-Makefile
-src/Makefile
-])
-AC_OUTPUT
-
diff --git a/gst-app/meson.build b/gst-app/meson.build
new file mode 100644
index 0000000..f30c244
--- /dev/null
+++ b/gst-app/meson.build
@@ -0,0 +1,6 @@
+app_sources = [
+ 'src/main.c',
+ 'src/play.c'
+ ]
+
+executable('gst-app', app_sources, dependencies : [gst_dep])
diff --git a/gst-app/src/Makefile.am b/gst-app/src/Makefile.am
deleted file mode 100644
index 28e69a3..0000000
--- a/gst-app/src/Makefile.am
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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 play.c
-
-# list of headers we're not going to install
-noinst_HEADERS = gst-app.h play.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)
diff --git a/gst-app/src/main.c b/gst-app/src/main.c
index 5ad0df0..8970400 100644
--- a/gst-app/src/main.c
+++ b/gst-app/src/main.c
@@ -105,11 +105,6 @@ main (int argc, char *argv[])
GError *err = NULL;
gint i, num;
- /* Before calling any GLib or GStreamer function, we must initialise
- * the GLib threading system */
- if (!g_thread_supported())
- g_thread_init (NULL);
-
ctx = g_option_context_new ("[FILE1] [FILE2] ...");
g_option_context_add_group (ctx, gst_init_get_option_group ());
g_option_context_add_main_entries (ctx, entries, NULL);
diff --git a/gst-app/src/play.c b/gst-app/src/play.c
index 339ccab..f24fb1b 100644
--- a/gst-app/src/play.c
+++ b/gst-app/src/play.c
@@ -92,12 +92,10 @@ play_uri (const gchar * uri)
g_print ("Playing ...\n");
while (1) {
- GstFormat time_format;
gint64 dur, pos;
- time_format = GST_FORMAT_TIME;
- if (gst_element_query_duration (playbin, &time_format, &dur) &&
- gst_element_query_position (playbin, &time_format, &pos)) {
+ if (gst_element_query_duration (playbin, GST_FORMAT_TIME, &dur) &&
+ gst_element_query_position (playbin, GST_FORMAT_TIME, &pos)) {
g_print (" %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "\n",
GST_TIME_ARGS (pos), GST_TIME_ARGS (dur));
}
diff --git a/gst-plugin/.gitignore b/gst-plugin/.gitignore
index b864463..5236e1e 100644
--- a/gst-plugin/.gitignore
+++ b/gst-plugin/.gitignore
@@ -1,16 +1,2 @@
-aclocal.m4
-autom4te.cache
-autoregen.sh
-config.*
-configure
-libtool
-INSTALL
-Makefile.in
-depcomp
-install-sh
-ltmain.sh
-missing
-stamp-*
-my-plugin-*.tar.*
*~
diff --git a/gst-plugin/Makefile.am b/gst-plugin/Makefile.am
deleted file mode 100644
index 5ff2f58..0000000
--- a/gst-plugin/Makefile.am
+++ /dev/null
@@ -1,3 +0,0 @@
-SUBDIRS = src
-
-EXTRA_DIST = autogen.sh
diff --git a/gst-plugin/NEWS b/gst-plugin/NEWS
deleted file mode 100644
index 3474a99..0000000
--- a/gst-plugin/NEWS
+++ /dev/null
@@ -1 +0,0 @@
-Nothing much yet.
diff --git a/gst-plugin/README b/gst-plugin/README
deleted file mode 100644
index 1905684..0000000
--- a/gst-plugin/README
+++ /dev/null
@@ -1,34 +0,0 @@
-WHAT IT IS
-----------
-
-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 and templates might get added later on.
-
-HOW TO USE IT
--------------
-
-To use it, either make a copy for yourself and rename the parts or use the
-make_element script in tools. To create sources for "myfilter" based on the
-"gsttransform" template run:
-
-cd src;
-../tools/make_element myfilter gsttransform
-
-This will create gstmyfilter.c and gstmyfilter.h. Open them in an editor and
-start editing. There are several occurances of the string "template", update
-those with real values. The plugin will be called 'myfilter' and it will have
-one element called 'myfilter' too. Also look for "FIXME:" markers that point you
-to places where you need to edit the code.
-
-You still need to adjust the Makefile.am.
-
diff --git a/gst-plugin/autogen.sh b/gst-plugin/autogen.sh
deleted file mode 100755
index 9df38d3..0000000
--- a/gst-plugin/autogen.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-# you can either set the environment variables AUTOCONF, AUTOHEADER, AUTOMAKE,
-# ACLOCAL, AUTOPOINT and/or LIBTOOLIZE to the right versions, or leave them
-# unset and get the defaults
-
-autoreconf --verbose --force --install --make || {
- echo 'autogen.sh failed';
- exit 1;
-}
-
-./configure || {
- echo 'configure failed';
- exit 1;
-}
-
-echo
-echo "Now type 'make' to compile this module."
-echo
diff --git a/gst-plugin/configure.ac b/gst-plugin/configure.ac
deleted file mode 100644
index ea85c18..0000000
--- a/gst-plugin/configure.ac
+++ /dev/null
@@ -1,87 +0,0 @@
-dnl required version of autoconf
-AC_PREREQ([2.53])
-
-dnl TODO: fill in your package name and package version here
-AC_INIT([my-plugin-package],[0.10.0])
-
-dnl required versions of gstreamer and plugins-base
-GST_REQUIRED=0.10.16
-GSTPB_REQUIRED=0.10.16
-
-AC_CONFIG_SRCDIR([src/gstplugin.c])
-AC_CONFIG_HEADERS([config.h])
-
-dnl required version of automake
-AM_INIT_AUTOMAKE([1.10])
-
-dnl enable mainainer mode by default
-AM_MAINTAINER_MODE([enable])
-
-dnl check for tools (compiler etc.)
-AC_PROG_CC
-
-dnl required version of libtool
-LT_PREREQ([2.2.6])
-LT_INIT
-
-dnl give error and exit if we don't have pkgconfig
-AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, [ ], [
- AC_MSG_ERROR([You need to have pkg-config installed!])
-])
-
-dnl Check for the required version of GStreamer core (and gst-plugins-base)
-dnl This will export GST_CFLAGS and GST_LIBS variables for use in Makefile.am
-dnl
-dnl If you need libraries from gst-plugins-base here, also add:
-dnl for libgstaudio-0.10: gstreamer-audio-0.10 >= $GST_REQUIRED
-dnl for libgstvideo-0.10: gstreamer-video-0.10 >= $GST_REQUIRED
-dnl for libgsttag-0.10: gstreamer-tag-0.10 >= $GST_REQUIRED
-dnl for libgstpbutils-0.10: gstreamer-pbutils-0.10 >= $GST_REQUIRED
-dnl for libgstfft-0.10: gstreamer-fft-0.10 >= $GST_REQUIRED
-dnl for libgstinterfaces-0.10: gstreamer-interfaces-0.10 >= $GST_REQUIRED
-dnl for libgstrtp-0.10: gstreamer-rtp-0.10 >= $GST_REQUIRED
-dnl for libgstrtsp-0.10: gstreamer-rtsp-0.10 >= $GST_REQUIRED
-dnl etc.
-PKG_CHECK_MODULES(GST, [
- gstreamer-0.10 >= $GST_REQUIRED
- gstreamer-base-0.10 >= $GST_REQUIRED
- gstreamer-controller-0.10 >= $GST_REQUIRED
-], [
- AC_SUBST(GST_CFLAGS)
- AC_SUBST(GST_LIBS)
-], [
- AC_MSG_ERROR([
- You need to install or upgrade the GStreamer development
- packages on your system. On debian-based systems these are
- libgstreamer0.10-dev and libgstreamer-plugins-base0.10-dev.
- on RPM-based systems gstreamer0.10-devel, libgstreamer0.10-devel
- or similar. The minimum version required is $GST_REQUIRED.
- ])
-])
-
-dnl check if compiler understands -Wall (if yes, add -Wall to GST_CFLAGS)
-AC_MSG_CHECKING([to see if compiler understands -Wall])
-save_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wall"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ], [ ])], [
- GST_CFLAGS="$GST_CFLAGS -Wall"
- AC_MSG_RESULT([yes])
-], [
- AC_MSG_RESULT([no])
-])
-
-dnl set the plugindir where plugins should be installed (for src/Makefile.am)
-if test "x${prefix}" = "x$HOME"; then
- plugindir="$HOME/.gstreamer-0.10/plugins"
-else
- plugindir="\$(libdir)/gstreamer-0.10"
-fi
-AC_SUBST(plugindir)
-
-dnl set proper LDFLAGS for plugins
-GST_PLUGIN_LDFLAGS='-module -avoid-version -export-symbols-regex [_]*\(gst_\|Gst\|GST_\).*'
-AC_SUBST(GST_PLUGIN_LDFLAGS)
-
-AC_CONFIG_FILES([Makefile src/Makefile])
-AC_OUTPUT
-
diff --git a/gst-plugin/meson.build b/gst-plugin/meson.build
new file mode 100644
index 0000000..01a21e9
--- /dev/null
+++ b/gst-plugin/meson.build
@@ -0,0 +1,52 @@
+plugin_c_args = ['-DHAVE_CONFIG_H']
+
+cdata = configuration_data()
+cdata.set_quoted('PACKAGE_VERSION', gst_version)
+cdata.set_quoted('PACKAGE', 'gst-template-plugin')
+cdata.set_quoted('GST_LICENSE', 'LGPL')
+cdata.set_quoted('GST_API_VERSION', api_version)
+cdata.set_quoted('GST_PACKAGE_NAME', 'GStreamer template Plug-ins')
+cdata.set_quoted('GST_PACKAGE_ORIGIN', 'https://gstreamer.freedesktop.org')
+configure_file(output : 'config.h', configuration : cdata)
+
+gstaudio_dep = dependency('gstreamer-audio-1.0',
+ fallback: ['gst-plugins-base', 'audio_dep'])
+
+# Plugin 1
+plugin_sources = [
+ 'src/gstplugin.c'
+ ]
+
+gstpluginexample = library('gstplugin',
+ plugin_sources,
+ c_args: plugin_c_args,
+ dependencies : [gst_dep],
+ install : true,
+ install_dir : plugins_install_dir,
+)
+
+# Plugin 2 (audio filter example)
+audiofilter_sources = [
+ 'src/gstaudiofilter.c',
+ ]
+
+gstaudiofilterexample = library('gstaudiofilterexample',
+ audiofilter_sources,
+ c_args: plugin_c_args,
+ dependencies : [gst_dep, gstaudio_dep],
+ install : true,
+ install_dir : plugins_install_dir,
+)
+
+# The TEMPLATE Plugin
+### gstTEMPLATE_sources = [
+### 'src/gstTEMPLATE.c',
+### ]
+
+###gstTEMPLATEexample = library('gstTEMPLATE',
+### gstTEMPLATE_sources,
+### c_args: plugin_c_args,
+### dependencies : [gst_dep, gstbase_dep],
+### install : true,
+### install_dir : plugins_install_dir,
+###)
diff --git a/gst-plugin/src/Makefile.am b/gst-plugin/src/Makefile.am
deleted file mode 100644
index 8f2bc4b..0000000
--- a/gst-plugin/src/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
-# Note: plugindir is set in configure
-
-##############################################################################
-# TODO: change libgstplugin.la to something else, e.g. libmysomething.la #
-##############################################################################
-plugin_LTLIBRARIES = libgstplugin.la
-
-##############################################################################
-# TODO: for the next set of variables, name the prefix if you named the .la, #
-# e.g. libmysomething.la => libmysomething_la_SOURCES #
-# libmysomething_la_CFLAGS #
-# libmysomething_la_LIBADD #
-# libmysomething_la_LDFLAGS #
-##############################################################################
-
-# sources used to compile this plug-in
-libgstplugin_la_SOURCES = gstplugin.c gstplugin.h
-
-# compiler and linker flags used to compile this plugin, set in configure.ac
-libgstplugin_la_CFLAGS = $(GST_CFLAGS)
-libgstplugin_la_LIBADD = $(GST_LIBS)
-libgstplugin_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-libgstplugin_la_LIBTOOLFLAGS = --tag=disable-static
-
-# headers we need but don't want installed
-noinst_HEADERS = gstplugin.h
diff --git a/gst-plugin/src/gstaudiofilter.c b/gst-plugin/src/gstaudiofilter.c
index 462b763..894a529 100644
--- a/gst-plugin/src/gstaudiofilter.c
+++ b/gst-plugin/src/gstaudiofilter.c
@@ -1,7 +1,7 @@
-/*
- * GStreamer
+/* GStreamer audio filter example class
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2003> David Schleef <ds@schleef.org>
+ * Copyright (C) <2020> Niels De Graef <niels.degraef@gmail.com>
* Copyright (C) YEAR AUTHOR_NAME AUTHOR_EMAIL
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -55,7 +55,7 @@
* ]|
* </refsect2>
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -65,31 +65,19 @@
#include <gst/audio/gstaudiofilter.h>
#include <string.h>
-GST_DEBUG_CATEGORY_STATIC (gst_plugin_template_debug);
-#define GST_CAT_DEFAULT gst_plugin_template_debug
-
-typedef struct _GstPluginTemplate GstPluginTemplate;
-typedef struct _GstPluginTemplateClass GstPluginTemplateClass;
+GST_DEBUG_CATEGORY_STATIC (audiofiltertemplate_debug);
+#define GST_CAT_DEFAULT audiofiltertemplate_debug
-#define GST_TYPE_PLUGIN_TEMPLATE \
- (gst_plugin_template_get_type())
-#define GST_PLUGIN_TEMPLATE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplate))
-#define GST_PLUGIN_TEMPLATE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplateClass))
-#define GST_IS_PLUGIN_TEMPLATE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLUGIN_TEMPLATE))
-#define GST_IS_PLUGIN_TEMPLATE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLUGIN_TEMPLATE))
+#define GST_TYPE_AUDIO_FILTER_TEMPLATE (gst_audio_filter_template_get_type())
+G_DECLARE_FINAL_TYPE (GstAudioFilterTemplate, gst_audio_filter_template,
+ GST, AUDIO_FILTER_TEMPLATE, GstAudioFilter);
-struct _GstPluginTemplate
+struct _GstAudioFilterTemplate
{
GstAudioFilter audiofilter;
-};
-struct _GstPluginTemplateClass
-{
- GstAudioFilterClass parent_class;
+ /* here you can add additional per-instance
+ * data such as properties */
};
@@ -102,63 +90,51 @@ enum
enum
{
ARG_0
- /* FILL ME */
+ /* FILL ME */
};
-/* debug category for fltering log messages
- *
- * FIXME:exchange the string 'Template plugin' with your description
- */
-#define DEBUG_INIT(bla) \
- GST_DEBUG_CATEGORY_INIT (gst_plugin_template_debug, "plugin", 0, "Template plugin");
+G_DEFINE_TYPE (GstAudioFilterTemplate, gst_audio_filter_template,
+ GST_TYPE_AUDIO_FILTER);
-GST_BOILERPLATE_FULL (GstPluginTemplate, gst_plugin_template,
- GstAudioFilter, GST_TYPE_AUDIO_FILTER, DEBUG_INIT);
+GST_ELEMENT_REGISTER_DEFINE (audiofiltertemplate, "audiofiltertemplate",
+ GST_RANK_NONE, GST_TYPE_AUDIO_FILTER_TEMPLATE);
-static void gst_plugin_template_set_property (GObject * object,
+static void gst_audio_filter_template_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
-static void gst_plugin_template_get_property (GObject * object,
+static void gst_audio_filter_template_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
-static gboolean gst_plugin_template_setup (GstAudioFilter * filter,
- GstRingBufferSpec * spec);
-static GstFlowReturn gst_plugin_template_filter (GstBaseTransform * bt,
- GstBuffer * outbuf, GstBuffer * inbuf);
+static gboolean gst_audio_filter_template_setup (GstAudioFilter * filter,
+ const GstAudioInfo * info);
+static GstFlowReturn gst_audio_filter_template_filter (GstBaseTransform *
+ bt, GstBuffer * outbuf, GstBuffer * inbuf);
static GstFlowReturn
-gst_plugin_template_filter_inplace (GstBaseTransform * base_transform,
- GstBuffer * buf);
-
-#define ALLOWED_CAPS_STRING \
- GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS
+gst_audio_filter_template_filter_inplace (GstBaseTransform *
+ base_transform, GstBuffer * buf);
-/* GObject vmethod implementations */
+#if 0
+/* This means we support signed 16-bit pcm and signed 32-bit pcm in native
+ * endianness */
+#define SUPPORTED_CAPS_STRING \
+ GST_AUDIO_CAPS_MAKE("{ " GST_AUDIO_NE(S16) ", " GST_AUDIO_NE(S32) " }")
+#endif
-static void
-gst_plugin_template_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- GstAudioFilterClass *audiofilter_class = GST_AUDIO_FILTER_CLASS (klass);
- GstCaps *caps;
-
- gst_element_class_set_details_simple (element_class,
- "Plugin",
- "Filter/Effect/Audio",
- "FIXME:Filters audio",
- "AUTHOR_NAME AUTHOR_EMAIL");
-
- caps = gst_caps_from_string (ALLOWED_CAPS_STRING);
- gst_audio_filter_class_add_pad_templates (audiofilter_class, caps);
- gst_caps_unref (caps);
-}
+/* For simplicity only support 16-bit pcm in native endianness for starters */
+#define SUPPORTED_CAPS_STRING \
+ GST_AUDIO_CAPS_MAKE(GST_AUDIO_NE(S16))
+/* GObject vmethod implementations */
static void
-gst_plugin_template_class_init (GstPluginTemplateClass * klass)
+gst_audio_filter_template_class_init (GstAudioFilterTemplateClass * klass)
{
GObjectClass *gobject_class;
+ GstElementClass *element_class;
GstBaseTransformClass *btrans_class;
GstAudioFilterClass *audio_filter_class;
+ GstCaps *caps;
gobject_class = (GObjectClass *) klass;
+ element_class = (GstElementClass *) klass;
btrans_class = (GstBaseTransformClass *) klass;
audio_filter_class = (GstAudioFilterClass *) klass;
@@ -169,32 +145,40 @@ gst_plugin_template_class_init (GstPluginTemplateClass * klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
#endif
- gobject_class->set_property = gst_plugin_template_set_property;
- gobject_class->get_property = gst_plugin_template_get_property;
+ gobject_class->set_property = gst_audio_filter_template_set_property;
+ gobject_class->get_property = gst_audio_filter_template_get_property;
- /* this function will be called whenever the format changes */
- audio_filter_class->setup = gst_plugin_template_setup;
+ /* this function will be called when the format is set before the
+ * first buffer comes in, and whenever the format changes */
+ audio_filter_class->setup = gst_audio_filter_template_setup;
/* here you set up functions to process data (either in place, or from
* one input buffer to another output buffer); only one is required */
- btrans_class->transform = gst_plugin_template_filter;
- btrans_class->transform_ip = gst_plugin_template_filter_inplace;
+ btrans_class->transform = gst_audio_filter_template_filter;
+ btrans_class->transform_ip = gst_audio_filter_template_filter_inplace;
+ /* Set some basic metadata about your new element */
+ gst_element_class_set_details_simple (element_class, "Audio Filter Template", /* FIXME: short name */
+ "Filter/Effect/Audio", "Filters audio", /* FIXME: short description */
+ "Name <mail@example.com>"); /* FIXME: author */
+
+ caps = gst_caps_from_string (SUPPORTED_CAPS_STRING);
+ gst_audio_filter_class_add_pad_templates (audio_filter_class, caps);
+ gst_caps_unref (caps);
}
static void
-gst_plugin_template_init (GstPluginTemplate * plugin_template,
- GstPluginTemplateClass * g_class)
+gst_audio_filter_template_init (GstAudioFilterTemplate * filter)
{
- GST_DEBUG ("init");
-
- /* do stuff if you need to */
+ /* This function is called when a new filter object is created. You
+ * would typically do things like initialise properties to their
+ * default values here if needed. */
}
static void
-gst_plugin_template_set_property (GObject * object, guint prop_id,
+gst_audio_filter_template_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
- GstPluginTemplate *filter = GST_PLUGIN_TEMPLATE (object);
+ GstAudioFilterTemplate *filter = GST_AUDIO_FILTER_TEMPLATE (object);
GST_OBJECT_LOCK (filter);
switch (prop_id) {
@@ -206,10 +190,10 @@ gst_plugin_template_set_property (GObject * object, guint prop_id,
}
static void
-gst_plugin_template_get_property (GObject * object, guint prop_id,
+gst_audio_filter_template_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
- GstPluginTemplate *filter = GST_PLUGIN_TEMPLATE (object);
+ GstAudioFilterTemplate *filter = GST_AUDIO_FILTER_TEMPLATE (object);
GST_OBJECT_LOCK (filter);
switch (prop_id) {
@@ -221,16 +205,29 @@ gst_plugin_template_get_property (GObject * object, guint prop_id,
}
static gboolean
-gst_plugin_template_setup (GstAudioFilter * filter,
- GstRingBufferSpec * spec)
+gst_audio_filter_template_setup (GstAudioFilter * filter,
+ const GstAudioInfo * info)
{
- GstPluginTemplate *plugin_template;
+ GstAudioFilterTemplate *filter_template;
+ GstAudioFormat fmt;
+ gint chans, rate;
- plugin_template = GST_PLUGIN_TEMPLATE (filter);
+ filter_template = GST_AUDIO_FILTER_TEMPLATE (filter);
- /* if any setup needs to be done, do it here */
+ rate = GST_AUDIO_INFO_RATE (info);
+ chans = GST_AUDIO_INFO_CHANNELS (info);
+ fmt = GST_AUDIO_INFO_FORMAT (info);
- return TRUE; /* it's all good */
+ GST_INFO_OBJECT (filter_template, "format %d (%s), rate %d, %d channels",
+ fmt, GST_AUDIO_INFO_NAME (info), rate, chans);
+
+ /* if any setup needs to be done (like memory allocated), do it here */
+
+ /* The audio filter base class also saves the audio info in
+ * GST_AUDIO_FILTER_INFO(filter) so it's automatically available
+ * later from there as well */
+
+ return TRUE;
}
/* You may choose to implement either a copying filter or an
@@ -240,58 +237,87 @@ gst_plugin_template_setup (GstAudioFilter * filter,
* with a minimum of memory copies. */
static GstFlowReturn
-gst_plugin_template_filter (GstBaseTransform * base_transform,
+gst_audio_filter_template_filter (GstBaseTransform * base_transform,
GstBuffer * inbuf, GstBuffer * outbuf)
{
- GstPluginTemplate *plugin_template;
- GstAudioFilter *audiofilter;
-
- audiofilter = GST_AUDIO_FILTER (base_transform);
- plugin_template = GST_PLUGIN_TEMPLATE (base_transform);
-
- /* FIXME: do something interesting here. This simply copies the source
- * to the destination. */
-
- memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf),
- GST_BUFFER_SIZE (inbuf));
+ GstAudioFilterTemplate *filter = GST_AUDIO_FILTER_TEMPLATE (base_transform);
+ GstMapInfo map_in;
+ GstMapInfo map_out;
+
+ GST_LOG_OBJECT (filter, "transform buffer");
+
+ /* FIXME: do something interesting here. We simply copy the input data
+ * to the output buffer for now. */
+ if (gst_buffer_map (inbuf, &map_in, GST_MAP_READ)) {
+ if (gst_buffer_map (outbuf, &map_out, GST_MAP_WRITE)) {
+ g_assert (map_out.size == map_in.size);
+ memcpy (map_out.data, map_in.data, map_out.size);
+ gst_buffer_unmap (outbuf, &map_out);
+ }
+ gst_buffer_unmap (inbuf, &map_in);
+ }
return GST_FLOW_OK;
}
static GstFlowReturn
-gst_plugin_template_filter_inplace (GstBaseTransform * base_transform,
+gst_audio_filter_template_filter_inplace (GstBaseTransform * base_transform,
GstBuffer * buf)
{
- GstPluginTemplate *plugin_template;
- GstAudioFilter *audiofilter;
+ GstAudioFilterTemplate *filter = GST_AUDIO_FILTER_TEMPLATE (base_transform);
+ GstFlowReturn flow = GST_FLOW_OK;
+ GstMapInfo map;
- audiofilter = GST_AUDIO_FILTER (base_transform);
- plugin_template = GST_PLUGIN_TEMPLATE (base_transform);
+ GST_LOG_OBJECT (filter, "transform buffer in place");
- /* FIXME: do something interesting here. This simply copies the source
- * to the destination. */
+ /* FIXME: do something interesting here. Doing nothing means the input
+ * buffer is simply pushed out as is without any modification */
+ if (gst_buffer_map (buf, &map, GST_MAP_READWRITE)) {
+#if 0
+ switch (GST_AUDIO_FILTER_FORMAT (filter)) {
+ case GST_AUDIO_FORMAT_S16LE:
+ case GST_AUDIO_FORMAT_S16BE:{
+ gint16 *samples = map.data;
+ guint n_samples = map.size / sizeof (gint16);
+ guint i;
+
+ for (i = 0; i < n; ++n) {
+ samples[i] = samples[i];
+ }
+ break;
+ }
+ default:
+ g_warning ("Unexpected audio format %s!",
+ GST_AUDIO_INFO_NAME (GST_AUDIO_FILTER_INFO (filter)));
+ flow = GST_FLOW_ERROR;
+ break;
+ }
+#endif
+ gst_buffer_unmap (buf, &map);
+ }
- return GST_FLOW_OK;
+ return flow;
}
static gboolean
plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "plugin", GST_RANK_NONE,
- GST_TYPE_PLUGIN_TEMPLATE);
+ /* Register debug category for filtering log messages
+ * FIXME:exchange the string 'Template plugin' with your description */
+ GST_DEBUG_CATEGORY_INIT (audiofiltertemplate_debug, "audiofiltertemplate", 0,
+ "Audio filter template example");
+
+ /* This is the name used in gst-launch-1.0 and gst_element_factory_make() */
+ return GST_ELEMENT_REGISTER (audiofiltertemplate, plugin);
}
/* gstreamer looks for this structure to register plugins
*
* FIXME:exchange the string 'Template plugin' with you plugin description
*/
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
- "plugin",
- "Template plugin",
+ audiofilterexample,
+ "Audio filter example plugin",
plugin_init,
- VERSION, "LGPL",
- "GStreamer",
- "http://gstreamer.net/"
-);
+ PACKAGE_VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
diff --git a/gst-plugin/src/gstplugin.c b/gst-plugin/src/gstplugin.c
index 464be87..f43e28b 100644
--- a/gst-plugin/src/gstplugin.c
+++ b/gst-plugin/src/gstplugin.c
@@ -96,35 +96,23 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("ANY")
);
-GST_BOILERPLATE (GstPluginTemplate, gst_plugin_template, GstElement,
- GST_TYPE_ELEMENT);
+#define gst_plugin_template_parent_class parent_class
+G_DEFINE_TYPE (GstPluginTemplate, gst_plugin_template, GST_TYPE_ELEMENT);
-static void gst_plugin_template_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_plugin_template_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
+GST_ELEMENT_REGISTER_DEFINE (plugin_template, "plugin_template", GST_RANK_NONE,
+ GST_TYPE_PLUGIN_TEMPLATE);
-static gboolean gst_plugin_template_set_caps (GstPad * pad, GstCaps * caps);
-static GstFlowReturn gst_plugin_template_chain (GstPad * pad, GstBuffer * buf);
+static void gst_plugin_template_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_plugin_template_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
-/* GObject vmethod implementations */
-
-static void
-gst_plugin_template_base_init (gpointer gclass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
-
- gst_element_class_set_details_simple(element_class,
- "Plugin",
- "FIXME:Generic",
- "FIXME:Generic Template Element",
- "AUTHOR_NAME AUTHOR_EMAIL");
+static gboolean gst_plugin_template_sink_event (GstPad * pad,
+ GstObject * parent, GstEvent * event);
+static GstFlowReturn gst_plugin_template_chain (GstPad * pad,
+ GstObject * parent, GstBuffer * buf);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_factory));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_factory));
-}
+/* GObject vmethod implementations */
/* initialize the plugin's class */
static void
@@ -142,31 +130,38 @@ gst_plugin_template_class_init (GstPluginTemplateClass * klass)
g_object_class_install_property (gobject_class, PROP_SILENT,
g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
FALSE, G_PARAM_READWRITE));
+
+ gst_element_class_set_details_simple (gstelement_class,
+ "Plugin",
+ "FIXME:Generic",
+ "FIXME:Generic Template Element", "AUTHOR_NAME AUTHOR_EMAIL");
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&src_factory));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&sink_factory));
}
/* initialize the new element
* instantiate pads and add them to element
- * set pad calback functions
+ * set pad callback functions
* initialize instance structure
*/
static void
-gst_plugin_template_init (GstPluginTemplate * filter,
- GstPluginTemplateClass * gclass)
+gst_plugin_template_init (GstPluginTemplate * filter)
{
filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
- gst_pad_set_setcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR(gst_plugin_template_set_caps));
- gst_pad_set_getcaps_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));
+ gst_pad_set_event_function (filter->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_plugin_template_sink_event));
gst_pad_set_chain_function (filter->sinkpad,
- GST_DEBUG_FUNCPTR(gst_plugin_template_chain));
+ GST_DEBUG_FUNCPTR (gst_plugin_template_chain));
+ GST_PAD_SET_PROXY_CAPS (filter->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
- gst_pad_set_getcaps_function (filter->srcpad,
- GST_DEBUG_FUNCPTR(gst_pad_proxy_getcaps));
-
- gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+ GST_PAD_SET_PROXY_CAPS (filter->srcpad);
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
+
filter->silent = FALSE;
}
@@ -204,29 +199,47 @@ gst_plugin_template_get_property (GObject * object, guint prop_id,
/* GstElement vmethod implementations */
-/* this function handles the link with other elements */
+/* this function handles sink events */
static gboolean
-gst_plugin_template_set_caps (GstPad * pad, GstCaps * caps)
+gst_plugin_template_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstPluginTemplate *filter;
- GstPad *otherpad;
+ gboolean ret;
+
+ filter = GST_PLUGIN_TEMPLATE (parent);
- filter = GST_PLUGIN_TEMPLATE (gst_pad_get_parent (pad));
- otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
- gst_object_unref (filter);
+ GST_LOG_OBJECT (filter, "Received %s event: %" GST_PTR_FORMAT,
+ GST_EVENT_TYPE_NAME (event), event);
- return gst_pad_set_caps (otherpad, caps);
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ /* do something with the caps */
+
+ /* and forward */
+ ret = gst_pad_event_default (pad, parent, event);
+ break;
+ }
+ default:
+ ret = gst_pad_event_default (pad, parent, event);
+ break;
+ }
+ return ret;
}
/* chain function
* this function does the actual processing
*/
static GstFlowReturn
-gst_plugin_template_chain (GstPad * pad, GstBuffer * buf)
+gst_plugin_template_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstPluginTemplate *filter;
- filter = GST_PLUGIN_TEMPLATE (GST_OBJECT_PARENT (pad));
+ filter = GST_PLUGIN_TEMPLATE (parent);
if (filter->silent == FALSE)
g_print ("I'm plugged, therefore I'm in.\n");
@@ -243,20 +256,19 @@ gst_plugin_template_chain (GstPad * pad, GstBuffer * buf)
static gboolean
plugin_init (GstPlugin * plugin)
{
- /* debug category for fltering log messages
+ /* debug category for filtering log messages
*
* exchange the string 'Template plugin' with your description
*/
GST_DEBUG_CATEGORY_INIT (gst_plugin_template_debug, "plugin",
0, "Template plugin");
- return gst_element_register (plugin, "plugin", GST_RANK_NONE,
- GST_TYPE_PLUGIN_TEMPLATE);
+ return GST_ELEMENT_REGISTER (plugin_template, plugin);
}
-/* PACKAGE: this is usually set by autotools depending on some _INIT macro
- * in configure.ac and then written into and defined in config.h, but we can
- * just set it ourselves here in case someone doesn't use autotools to
+/* PACKAGE: this is usually set by meson depending on some _INIT macro
+ * in meson.build and then written into and defined in config.h, but we can
+ * just set it ourselves here in case someone doesn't use meson to
* compile this code. GST_PLUGIN_DEFINE needs PACKAGE to be defined.
*/
#ifndef PACKAGE
@@ -267,14 +279,9 @@ plugin_init (GstPlugin * plugin)
*
* exchange the string 'Template plugin' with your plugin description
*/
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
- "plugin",
- "Template plugin",
+ plugin,
+ "plugin_template",
plugin_init,
- VERSION,
- "LGPL",
- "GStreamer",
- "http://gstreamer.net/"
-)
+ PACKAGE_VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/gst-plugin/src/gstplugin.h b/gst-plugin/src/gstplugin.h
index f1fe4ed..5d6a647 100644
--- a/gst-plugin/src/gstplugin.h
+++ b/gst-plugin/src/gstplugin.h
@@ -2,6 +2,7 @@
* GStreamer
* Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
* Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ * Copyright (C) 2020 Niels De Graef <niels.degraef@gmail.com>
* Copyright (C) YEAR AUTHOR_NAME AUTHOR_EMAIL
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -50,20 +51,9 @@
G_BEGIN_DECLS
-/* #defines don't like whitespacey bits */
-#define GST_TYPE_PLUGIN_TEMPLATE \
- (gst_plugin_template_get_type())
-#define GST_PLUGIN_TEMPLATE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplate))
-#define GST_PLUGIN_TEMPLATE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplateClass))
-#define GST_IS_PLUGIN_TEMPLATE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLUGIN_TEMPLATE))
-#define GST_IS_PLUGIN_TEMPLATE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLUGIN_TEMPLATE))
-
-typedef struct _GstPluginTemplate GstPluginTemplate;
-typedef struct _GstPluginTemplateClass GstPluginTemplateClass;
+#define GST_TYPE_PLUGIN_TEMPLATE (gst_plugin_template_get_type())
+G_DECLARE_FINAL_TYPE (GstPluginTemplate, gst_plugin_template,
+ GST, PLUGIN_TEMPLATE, GstElement)
struct _GstPluginTemplate
{
@@ -74,13 +64,6 @@ struct _GstPluginTemplate
gboolean silent;
};
-struct _GstPluginTemplateClass
-{
- GstElementClass parent_class;
-};
-
-GType gst_plugin_template_get_type (void);
-
G_END_DECLS
#endif /* __GST_PLUGIN_TEMPLATE_H__ */
diff --git a/gst-plugin/src/gsttransform.c b/gst-plugin/src/gsttransform.c
index 6cf223e..34fb120 100644
--- a/gst-plugin/src/gsttransform.c
+++ b/gst-plugin/src/gsttransform.c
@@ -37,8 +37,8 @@
#endif
#include <gst/gst.h>
-#include <gst/base/gstbasetransform.h>
-#include <gst/controller/gstcontroller.h>
+#include <gst/base/base.h>
+#include <gst/controller/controller.h>
#include "gsttransform.h"
@@ -62,82 +62,76 @@ enum
*
* FIXME:describe the real formats here.
*/
-static GstStaticPadTemplate sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("ANY")
-);
-
-static GstStaticPadTemplate src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("ANY")
-);
-
-/* debug category for fltering log messages
- *
- * FIXME:exchange the string 'Template plugin' with your description
- */
-#define DEBUG_INIT(bla) \
- GST_DEBUG_CATEGORY_INIT (gst_plugin_template_debug, "plugin", 0, "Template plugin");
-
-GST_BOILERPLATE_FULL (GstPluginTemplate, gst_plugin_template, GstBaseTransform,
- GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
-
-static void gst_plugin_template_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_plugin_template_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static GstFlowReturn gst_plugin_template_transform_ip (GstBaseTransform * base,
- GstBuffer * outbuf);
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("ANY")
+ );
+
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("ANY")
+ );
+
+#define gst_plugin_template_parent_class parent_class
+G_DEFINE_TYPE (GstPluginTemplate, gst_plugin_template, GST_TYPE_BASE_TRANSFORM);
+GST_ELEMENT_REGISTER_DEFINE (plugin_template, "plugin_template", GST_RANK_NONE,
+ GST_TYPE_PLUGIN_TEMPLATE);
+
+static void gst_plugin_template_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_plugin_template_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static GstFlowReturn gst_plugin_template_transform_ip (GstBaseTransform *
+ base, GstBuffer * outbuf);
/* GObject vmethod implementations */
-static void
-gst_plugin_template_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_set_details_simple (element_class,
- "Plugin",
- "Generic/Filter",
- "FIXME:Generic Template Filter",
- "AUTHOR_NAME AUTHOR_EMAIL");
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
-}
-
/* initialize the plugin's class */
static void
gst_plugin_template_class_init (GstPluginTemplateClass * klass)
{
GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+
gobject_class->set_property = gst_plugin_template_set_property;
gobject_class->get_property = gst_plugin_template_get_property;
g_object_class_install_property (gobject_class, PROP_SILENT,
- g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
+ g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
FALSE, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
+ gst_element_class_set_details_simple (gstelement_class,
+ "Plugin",
+ "Generic/Filter",
+ "FIXME:Generic Template Filter", "AUTHOR_NAME AUTHOR_EMAIL");
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&src_template));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&sink_template));
+
GST_BASE_TRANSFORM_CLASS (klass)->transform_ip =
GST_DEBUG_FUNCPTR (gst_plugin_template_transform_ip);
+
+ /* debug category for fltering log messages
+ *
+ * FIXME:exchange the string 'Template plugin' with your description
+ */
+ GST_DEBUG_CATEGORY_INIT (gst_plugin_template_debug, "plugin", 0,
+ "Template plugin");
}
/* initialize the new element
* initialize instance structure
*/
static void
-gst_plugin_template_init (GstPluginTemplate *filter, GstPluginTemplateClass * klass)
+gst_plugin_template_init (GstPluginTemplate * filter)
{
filter->silent = FALSE;
}
@@ -184,11 +178,11 @@ gst_plugin_template_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
GstPluginTemplate *filter = GST_PLUGIN_TEMPLATE (base);
if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (outbuf)))
- gst_object_sync_values (G_OBJECT (filter), GST_BUFFER_TIMESTAMP (outbuf));
+ gst_object_sync_values (GST_OBJECT (filter), GST_BUFFER_TIMESTAMP (outbuf));
if (filter->silent == FALSE)
g_print ("I'm plugged, therefore I'm in.\n");
-
+
/* FIXME: do something interesting here. This simply copies the source
* to the destination. */
@@ -203,25 +197,16 @@ gst_plugin_template_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
static gboolean
plugin_init (GstPlugin * plugin)
{
- /* initialize gst controller library */
- gst_controller_init(NULL, NULL);
-
- return gst_element_register (plugin, "plugin", GST_RANK_NONE,
- GST_TYPE_PLUGIN_TEMPLATE);
+ return GST_ELEMENT_REGISTER (plugin_template, plugin);
}
/* gstreamer looks for this structure to register plugins
*
* FIXME:exchange the string 'Template plugin' with you plugin description
*/
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
- "plugin",
- "Template plugin",
+ plugin,
+ "plugin_template",
plugin_init,
- VERSION,
- "LGPL",
- "GStreamer",
- "http://gstreamer.net/"
-)
+ PACKAGE_VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/gst-plugin/src/gsttransform.h b/gst-plugin/src/gsttransform.h
index be9ce86..548b2f8 100644
--- a/gst-plugin/src/gsttransform.h
+++ b/gst-plugin/src/gsttransform.h
@@ -1,6 +1,7 @@
/*
* GStreamer
* Copyright (C) 2006 Stefan Kost <ensonic@users.sf.net>
+ * Copyright (C) 2020 Niels De Graef <niels.degraef@gmail.com>
* Copyright (C) YEAR AUTHOR_NAME AUTHOR_EMAIL
*
* This library is free software; you can redistribute it and/or
@@ -27,19 +28,9 @@
G_BEGIN_DECLS
-#define GST_TYPE_PLUGIN_TEMPLATE \
- (gst_plugin_template_get_type())
-#define GST_PLUGIN_TEMPLATE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplate))
-#define GST_PLUGIN_TEMPLATE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLUGIN_TEMPLATE,GstPluginTemplateClass))
-#define GST_IS_PLUGIN_TEMPLATE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLUGIN_TEMPLATE))
-#define GST_IS_PLUGIN_TEMPLATE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLUGIN_TEMPLATE))
-
-typedef struct _GstPluginTemplate GstPluginTemplate;
-typedef struct _GstPluginTemplateClass GstPluginTemplateClass;
+#define GST_TYPE_PLUGIN_TEMPLATE (gst_plugin_template_get_type())
+G_DECLARE_FINAL_TYPE (GstPluginTemplate, gst_plugin_template,
+ GST, PLUGIN_TEMPLATE, GstBaseTransform)
struct _GstPluginTemplate {
GstBaseTransform element;
@@ -47,12 +38,6 @@ struct _GstPluginTemplate {
gboolean silent;
};
-struct _GstPluginTemplateClass {
- GstBaseTransformClass parent_class;
-};
-
-GType gst_plugin_template_get_type (void);
-
G_END_DECLS
#endif /* __GST_PLUGIN_TEMPLATE_H__ */
diff --git a/gst-plugin/tools/make_element b/gst-plugin/tools/make_element
index 3ae7d18..fd79c2f 100755
--- a/gst-plugin/tools/make_element
+++ b/gst-plugin/tools/make_element
@@ -3,6 +3,7 @@
Template=$1;
srcfile=$2.c;
srcfile_h=$2.h;
+meson_build=../meson.build;
if test x"$1" = x ; then
echo "$0 Objectname [srcfile]\n";
@@ -45,8 +46,7 @@ sed \
-e "s/gstplugin\.h/gst$filename.h/g" \
-e "s/gsttransform\.h/gst$filename.h/g" \
-e "s/GstPluginTemplate/Gst$Template/g" \
- -e "s/gst_plugin_template/gst_$template_/g" \
- -e "s/gst_type_plugin_template/gst_$template_/g" \
+ -e "s/plugin_template/$template_/g" \
-e "s/GST_PLUGIN_TEMPLATE/GST_$TEMPLATE/g" \
-e "s/GST_TYPE_PLUGIN_TEMPLATE/GST_TYPE_$TEMPLATE/g" \
-e 's/\$I[d]: \([^$]*\)\$/\1/g' \
@@ -63,9 +63,9 @@ if [ -e $srcfile_h ]; then
sed \
-e 's/gstplugin\.c/SOURCEFILE/g' \
-e "s/GstPluginTemplate/Gst$Template/g" \
- -e "s/gst_plugin_template/gst_$template_/g" \
+ -e "s/plugin_template/$template_/g" \
-e "s/gst_type_plugin_template/gst_$template_/g" \
- -e "s/GST_PLUGIN_TEMPLATE/GST_$TEMPLATE/g" \
+ -e "s/PLUGIN_TEMPLATE/$TEMPLATE/g" \
-e "s/GST_TYPE_PLUGIN_TEMPLATE/GST_TYPE_$TEMPLATE/g" \
-e "s/GST_IS_PLUGIN_TEMPLATE/GST_IS_$TEMPLATE/g" \
-e 's/\$I[d]: \([^$]*\)\$/\1/g' \
@@ -79,3 +79,9 @@ if [ -e $srcfile_h ]; then
$srcfile_h >gst$filename.h.tmp && mv gst$filename.h.tmp gst$filename.h
fi
+if [ -e $meson_build ]; then
+ sed \
+ -e "s/TEMPLATE/$template/g" \
+ -e "s/###//g" \
+ $meson_build > $meson_build.tmp && mv $meson_build.tmp $meson_build
+fi \ No newline at end of file
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..815ec87
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,17 @@
+project('gst-template', 'c', version : '1.19.0.1', license : 'LGPL')
+
+plugins_install_dir = join_paths(get_option('libdir'), 'gstreamer-1.0')
+
+cc = meson.get_compiler('c')
+
+gst_version = meson.project_version()
+
+api_version = '1.0'
+
+gst_dep = dependency('gstreamer-1.0', version : '>=1.19',
+ required : true, fallback : ['gstreamer', 'gst_dep'])
+gstbase_dep = dependency('gstreamer-base-1.0', version : '>=1.19',
+ fallback : ['gstreamer', 'gst_base_dep'])
+
+subdir('gst-app')
+subdir('gst-plugin')