2012-02-19 23:54:39 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
|
|
prefix=gst
|
|
|
|
templatedir=element-templates
|
|
|
|
|
|
|
|
while [ "$1" ] ; do
|
|
|
|
case $1 in
|
|
|
|
--help)
|
|
|
|
cat <<-EOF
|
|
|
|
Usage: gst-project-maker [OPTIONS] PROJECT_NAME
|
|
|
|
Create an autotools project based on GStreamer from a template.
|
|
|
|
Options:
|
|
|
|
--help Print this information
|
|
|
|
--prefix PREFIX Use PREFIX instead of "gst"
|
|
|
|
Example: 'gst-project-maker my_project' will create the project gst-my-project.
|
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
--prefix)
|
|
|
|
shift
|
|
|
|
prefix=$1
|
|
|
|
;;
|
|
|
|
-*)
|
|
|
|
echo Unknown option: $1
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ "$name" = "" ]; then
|
|
|
|
name=$1
|
|
|
|
else
|
|
|
|
echo Ignored: $1
|
|
|
|
fi
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$name" = "" ] ; then
|
|
|
|
echo "Usage: gst-project-maker [OPTIONS] PROJECT_NAME"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
PREFIX=$(echo $prefix | sed -e 's/\(.*\)/\U\1/')
|
|
|
|
NAME=$(echo $name | sed -e 's/\(.*\)/\U\1/')
|
|
|
|
Prefix=$(echo $prefix | sed -e 's/_\(.\)/\U\1/g' -e 's/^\(.\)/\U\1/')
|
|
|
|
Name=$(echo $name | sed -e 's/_\(.\)/\U\1/g' -e 's/^\(.\)/\U\1/')
|
|
|
|
|
2012-02-20 19:42:23 +00:00
|
|
|
if [ "$prefix" != "gst" ] ; then
|
|
|
|
cmdline_prefix="--prefix $prefix"
|
|
|
|
else
|
|
|
|
cmdline_prefix=""
|
|
|
|
fi
|
|
|
|
|
2012-02-19 23:54:39 +00:00
|
|
|
GST_IS_REPLACE=${PREFIX}_IS_${NAME}
|
|
|
|
GST_REPLACE=${PREFIX}_${NAME}
|
|
|
|
GST_TYPE_REPLACE=${PREFIX}_TYPE_${NAME}
|
|
|
|
GstReplace=${Prefix}${Name}
|
|
|
|
gst_replace=${prefix}_${name}
|
|
|
|
gst__replace=${prefix}-${name}
|
|
|
|
gstreplace=${prefix}$(echo $name | sed -e 's/_//g')
|
|
|
|
replace=$(echo $name | sed -e 's/_//g')
|
|
|
|
|
|
|
|
if [ "$REAL_NAME" = "" ] ; then
|
|
|
|
REAL_NAME=FIXME
|
|
|
|
fi
|
|
|
|
if [ "$EMAIL_ADDRESS" = "" ] ; then
|
|
|
|
EMAIL_ADDRESS=fixme@example.com
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
basedir=`pwd`/$gst__replace
|
|
|
|
|
|
|
|
rm -rf $basedir
|
|
|
|
mkdir $basedir
|
|
|
|
|
|
|
|
cat >$basedir/AUTHORS <<EOF
|
|
|
|
$REAL_NAME <$EMAIL_ADDRESS>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat >$basedir/COPYING <<EOF
|
|
|
|
Put your license here.
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat >$basedir/ChangeLog <<EOF
|
|
|
|
Put your changelog here.
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat >$basedir/NEWS <<EOF
|
|
|
|
News about your project.
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat >$basedir/README <<EOF
|
|
|
|
README for your project.
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat >$basedir/autogen.sh <<EOF
|
|
|
|
#!/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
|
|
|
|
EOF
|
|
|
|
chmod 755 $basedir/autogen.sh
|
|
|
|
|
|
|
|
cat >$basedir/configure.ac <<EOF
|
|
|
|
dnl required version of autoconf
|
|
|
|
AC_PREREQ([2.53])
|
|
|
|
|
|
|
|
dnl TODO: fill in your package name and package version here
|
2013-02-07 19:15:01 +00:00
|
|
|
AC_INIT([${gst__replace}],[1.0.0])
|
2012-02-19 23:54:39 +00:00
|
|
|
|
|
|
|
dnl required versions of gstreamer and plugins-base
|
2013-02-07 19:15:01 +00:00
|
|
|
GST_REQUIRED=1.0.0
|
|
|
|
GSTPB_REQUIRED=1.0.0
|
2012-02-19 23:54:39 +00:00
|
|
|
|
|
|
|
AC_CONFIG_SRCDIR([plugins/${gstreplace}.c])
|
|
|
|
AC_CONFIG_HEADERS([config.h])
|
|
|
|
|
|
|
|
dnl required version of automake
|
|
|
|
AM_INIT_AUTOMAKE([1.10])
|
|
|
|
AC_CONFIG_MACRO_DIR([m4])
|
|
|
|
|
|
|
|
dnl enable mainainer mode by default
|
|
|
|
AM_MAINTAINER_MODE([enable])
|
|
|
|
|
|
|
|
dnl check for tools (compiler etc.)
|
|
|
|
AC_PROG_CC
|
2012-02-20 19:42:23 +00:00
|
|
|
AM_PROG_CC_C_O
|
2012-02-19 23:54:39 +00:00
|
|
|
|
|
|
|
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:
|
2013-02-07 19:15:01 +00:00
|
|
|
dnl for libgstaudio-1.0: gstreamer-audio-1.0 >= \$GST_REQUIRED
|
|
|
|
dnl for libgstvideo-1.0: gstreamer-video-1.0 >= \$GST_REQUIRED
|
|
|
|
dnl for libgsttag-1.0: gstreamer-tag-1.0 >= \$GST_REQUIRED
|
|
|
|
dnl for libgstpbutils-1.0: gstreamer-pbutils-1.0 >= \$GST_REQUIRED
|
|
|
|
dnl for libgstfft-1.0: gstreamer-fft-1.0 >= \$GST_REQUIRED
|
|
|
|
dnl for libgstinterfaces-1.0: gstreamer-interfaces-1.0 >= \$GST_REQUIRED
|
|
|
|
dnl for libgstrtp-1.0: gstreamer-rtp-1.0 >= \$GST_REQUIRED
|
|
|
|
dnl for libgstrtsp-1.0: gstreamer-rtsp-1.0 >= \$GST_REQUIRED
|
2012-02-19 23:54:39 +00:00
|
|
|
dnl etc.
|
|
|
|
PKG_CHECK_MODULES(GST, [
|
2013-02-07 19:15:01 +00:00
|
|
|
gstreamer-1.0 >= \$GST_REQUIRED
|
|
|
|
gstreamer-base-1.0 >= \$GST_REQUIRED
|
|
|
|
gstreamer-controller-1.0 >= \$GST_REQUIRED
|
2012-02-19 23:54:39 +00:00
|
|
|
], [
|
|
|
|
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
|
2013-02-07 19:15:01 +00:00
|
|
|
libgstreamer1.0-dev and libgstreamer-plugins-base1.0-dev.
|
|
|
|
on RPM-based systems gstreamer1.0-devel, libgstreamer1.0-devel
|
2012-02-19 23:54:39 +00:00
|
|
|
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 plugins/Makefile.am)
|
|
|
|
if test "x\${prefix}" = "x\$HOME"; then
|
2013-02-07 19:15:01 +00:00
|
|
|
plugindir="\$HOME/.gstreamer-1.0/plugins"
|
2012-02-19 23:54:39 +00:00
|
|
|
else
|
2013-02-07 19:15:01 +00:00
|
|
|
plugindir="\\\$(libdir)/gstreamer-1.0"
|
2012-02-19 23:54:39 +00:00
|
|
|
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)
|
|
|
|
|
2012-02-20 19:42:23 +00:00
|
|
|
AC_CONFIG_FILES([Makefile plugins/Makefile tools/Makefile])
|
2012-02-19 23:54:39 +00:00
|
|
|
AC_OUTPUT
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat >$basedir/Makefile.am <<EOF
|
2012-02-20 19:42:23 +00:00
|
|
|
SUBDIRS = plugins tools
|
2012-02-19 23:54:39 +00:00
|
|
|
|
|
|
|
EXTRA_DIST = autogen.sh
|
|
|
|
|
|
|
|
ACLOCAL_AMFLAGS = -I m4
|
|
|
|
EOF
|
|
|
|
|
|
|
|
mkdir -p $basedir/m4
|
|
|
|
|
|
|
|
mkdir -p $basedir/plugins
|
|
|
|
|
|
|
|
cat >$basedir/plugins/Makefile.am <<EOF
|
|
|
|
plugin_LTLIBRARIES = lib$gstreplace.la
|
|
|
|
|
|
|
|
# sources used to compile this plug-in
|
2012-02-20 19:42:23 +00:00
|
|
|
lib${gstreplace}_la_SOURCES = ${gstreplace}plugin.c ${gstreplace}.c ${gstreplace}.h
|
2012-02-19 23:54:39 +00:00
|
|
|
|
|
|
|
# compiler and linker flags used to compile this plugin, set in configure.ac
|
|
|
|
lib${gstreplace}_la_CFLAGS = \$(GST_CFLAGS)
|
|
|
|
lib${gstreplace}_la_LIBADD = \$(GST_LIBS)
|
|
|
|
lib${gstreplace}_la_LDFLAGS = \$(GST_PLUGIN_LDFLAGS)
|
2012-10-24 10:16:39 +00:00
|
|
|
lib${gstreplace}_la_LIBTOOLFLAGS = \$(GST_PLUGIN_LIBTOOLFLAGS)
|
2012-02-19 23:54:39 +00:00
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
generate()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) $(date +%Y) $REAL_NAME <$EMAIL_ADDRESS>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the
|
|
|
|
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
|
|
|
|
* which case the following provisions apply instead of the ones
|
|
|
|
* mentioned above:
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 20:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2012-02-19 23:54:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2012-02-20 19:42:23 +00:00
|
|
|
#include "gstreplace.h"
|
2012-02-19 23:54:39 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
plugin_init (GstPlugin * plugin)
|
|
|
|
{
|
2012-02-20 19:42:23 +00:00
|
|
|
gst_element_register (plugin, "replace", GST_RANK_NONE,
|
|
|
|
GST_TYPE_REPLACE);
|
2012-02-19 23:54:39 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_PLUGIN_DEFINE (
|
|
|
|
GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
2012-04-05 16:02:56 +00:00
|
|
|
replace,
|
2012-02-19 23:54:39 +00:00
|
|
|
"FIXME Template plugin",
|
|
|
|
plugin_init,
|
|
|
|
VERSION,
|
|
|
|
"LGPL", /* FIXME */
|
|
|
|
"GStreamer",
|
|
|
|
"http://gstreamer.net/"
|
|
|
|
)
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
generate | sed \
|
|
|
|
-e "s/GST_BASE_REPLACE/$GST_BASE_REPLACE/g" \
|
|
|
|
-e "s/GST_TYPE_BASE_REPLACE/$GST_TYPE_BASE_REPLACE/g" \
|
|
|
|
-e "s/GstBaseReplace/$GstBaseReplace/g" \
|
|
|
|
-e "s/GST_IS_REPLACE/$GST_IS_REPLACE/g" \
|
|
|
|
-e "s/GST_REPLACE/$GST_REPLACE/g" \
|
|
|
|
-e "s/GST_TYPE_REPLACE/$GST_TYPE_REPLACE/g" \
|
|
|
|
-e "s/GstReplace/$GstReplace/g" \
|
|
|
|
-e "s/gst_replace/$gst_replace/g" \
|
|
|
|
-e "s/gstreplace/$gstreplace/g" \
|
2012-02-20 19:42:23 +00:00
|
|
|
-e "s/replace/$replace/g" >$basedir/plugins/${gstreplace}plugin.c
|
|
|
|
|
|
|
|
gst-indent $basedir/plugins/${gstreplace}plugin.c
|
|
|
|
rm -f $basedir/plugins/${gstreplace}plugin.c~
|
|
|
|
|
|
|
|
cat >$basedir/plugins/${gstreplace}.c <<EOF
|
|
|
|
/* This file should be replaced by element source generated by
|
|
|
|
* gst-element-maker, or by your own source code. To generate suitable
|
|
|
|
* element source using gst-element-maker, run:
|
|
|
|
*
|
|
|
|
* gst-element-maker $cmdline_prefix $replace BASE_CLASS
|
|
|
|
*
|
|
|
|
* Where BASE_CLASS is replaced by one of the base class templates,
|
|
|
|
* such as basesrc, basetransform, audiofilter, videofilter2, etc.
|
|
|
|
* Then copy the resulting $gstreplace.c file over this file, and
|
|
|
|
* $gstreplace.h over $gstreplace.h.
|
|
|
|
*/
|
|
|
|
/* The rest of this file is shim code to allow the project to compile */
|
|
|
|
EOF
|
2012-02-19 23:54:39 +00:00
|
|
|
|
2012-02-20 19:42:23 +00:00
|
|
|
cat >$basedir/plugins/${gstreplace}.h <<EOF
|
|
|
|
/* This file should be replaced by element header generated by
|
|
|
|
* gst-element-maker, or by your own source code. To generate suitable
|
|
|
|
* element header using gst-element-maker, run:
|
|
|
|
*
|
|
|
|
* gst-element-maker $cmdline_prefix $replace BASE_CLASS
|
|
|
|
*
|
|
|
|
* Where BASE_CLASS is replaced by one of the base class templates,
|
|
|
|
* such as basesrc, basetransform, audiofilter, videofilter2, etc.
|
|
|
|
* Then copy the resulting $gstreplace.h file over this file, and
|
|
|
|
* $gstreplace.c over $gstreplace.c.
|
|
|
|
*/
|
|
|
|
/* The rest of this file is shim code to allow the project to compile */
|
|
|
|
#define ${GST_TYPE_REPLACE} G_TYPE_NONE
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -p $basedir/tools
|
|
|
|
|
|
|
|
cat >$basedir/tools/Makefile.am <<EOF
|
|
|
|
bin_PROGRAMS = ${gst__replace}
|
|
|
|
|
|
|
|
# sources used to compile this plug-in
|
|
|
|
${gst_replace}_SOURCES = ${gstreplace}.c
|
|
|
|
|
|
|
|
# compiler and linker flags used to compile the program, set in configure.ac
|
|
|
|
${gst_replace}_CFLAGS = \$(GST_CFLAGS)
|
|
|
|
${gst_replace}_LDADD = \$(GST_LIBS)
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat >$basedir/tools/${gstreplace}.c <<EOF
|
|
|
|
/* This file should be replaced by application source generated by
|
|
|
|
* gst-app-maker, or by your own source code. To generate suitable
|
|
|
|
* app source using gst-app-maker, run:
|
|
|
|
*
|
|
|
|
* gst-app-maker $cmdline_prefix $replace
|
|
|
|
*
|
|
|
|
* Then copy the resulting $gstreplace.c file over this file.
|
|
|
|
*/
|
|
|
|
/* The rest of this file is shim code to allow the project to compile */
|
|
|
|
#include <stdio.h>
|
|
|
|
int main (void) { printf ("FIXME\n"); return 0; }
|
|
|
|
EOF
|
2012-02-19 23:54:39 +00:00
|
|
|
|
|
|
|
|