5 templatedir=element-templates
11 Usage: element-maker [OPTIONS] ELEMENT_NAME BASE_CLASS
12 Create a GStreamer element that subclasses BASE_CLASS.
14 --help Print this information
15 --prefix PREFIX Use PREFIX instead of "gst"
16 Example: 'element-maker my_element basetransform' will create the files
17 gstmyelement.c and gstmyelement.h that implement GstMyElement, a
18 subclass of GstBaseTransform, as an element named myelement.
27 echo Unknown option: $1
31 if [ "$name" = "" ]; then
33 elif [ "$class" = "" ]; then
42 if [ "$name" = "" -o "$class" = "" ] ; then
43 echo "Usage: element-maker [OPTIONS] ELEMENT_NAME BASE_CLASS"
47 if [ ! -f "element-templates/$class" ] ; then
48 echo "Template file for $class not found."
53 PREFIX=$(echo $prefix | sed -e 's/\(.*\)/\U\1/')
54 NAME=$(echo $name | sed -e 's/\(.*\)/\U\1/')
55 Prefix=$(echo $prefix | sed -e 's/_\(.\)/\U\1/g' -e 's/^\(.\)/\U\1/')
56 Name=$(echo $name | sed -e 's/_\(.\)/\U\1/g' -e 's/^\(.\)/\U\1/')
58 GST_IS_REPLACE=${PREFIX}_IS_${NAME}
59 GST_REPLACE=${PREFIX}_${NAME}
60 GST_TYPE_REPLACE=${PREFIX}_TYPE_${NAME}
61 GstReplace=${Prefix}${Name}
62 gst_replace=${prefix}_${name}
63 gstreplace=${prefix}$(echo $name | sed -e 's/_//g')
64 replace=$(echo $name | sed -e 's/_//g')
66 if [ "$REAL_NAME" = "" ] ; then
69 if [ "$EMAIL_ADDRESS" = "" ] ; then
70 EMAIL_ADDRESS=fixme@example.com
74 pkg=`grep -A 10000 '^% pkg-config' $templatedir/$class | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1`
75 GST_TYPE_BASE_REPLACE=`grep -A 10000 '^% TYPE_CLASS_NAME' $templatedir/$class | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1`
76 GstBaseReplace=`grep -A 10000 '^% ClassName' $templatedir/$class | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1`
77 pads=`grep -A 10000 '^% pads' $templatedir/$class | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1`
84 * Copyright (C) $(date +%Y) $REAL_NAME <$EMAIL_ADDRESS>
86 * This library is free software; you can redistribute it and/or
87 * modify it under the terms of the GNU Library General Public
88 * License as published by the Free Software Foundation; either
89 * version 2 of the License, or (at your option) any later version.
91 * This library is distributed in the hope that it will be useful,
92 * but WITHOUT ANY WARRANTY; without even the implied warranty of
93 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
94 * Library General Public License for more details.
96 * You should have received a copy of the GNU Library General Public
97 * License along with this library; if not, write to the
98 * Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
99 * Boston, MA 02110-1335, USA.
105 * SECTION:element-$gstreplace
107 * The $replace element does FIXME stuff.
110 * <title>Example launch line</title>
112 * gst-launch -v fakesrc ! $replace ! FIXME ! fakesink
114 * FIXME Describe what the pipeline does.
119 #grep -A 10000 '^% copyright' $templatedir/base | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
129 grep -A 10000 '^% includes' $templatedir/base | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
130 grep -A 10000 '^% includes' $templatedir/gobject | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
131 grep -A 10000 '^% includes' $templatedir/$class | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
134 #include "gstreplace.h"
140 grep -A 10000 '^% prototypes' $templatedir/base | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
141 grep -A 10000 '^% prototypes' $templatedir/gobject | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
142 grep -A 10000 '^% prototypes' $templatedir/$class | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
145 grep -A 10000 '^% prototypes' $templatedir/$each | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
161 grep -A 10000 '^% pad-template' $templatedir/$each | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
166 /* class initialization */
168 GST_BOILERPLATE (GstReplace, gst_replace, GstBaseReplace,
169 GST_TYPE_BASE_REPLACE);
172 gst_replace_base_init (gpointer g_class)
174 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
180 grep -A 10000 '^% base-init' $templatedir/$each | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
185 gst_element_class_set_details_simple (element_class, "FIXME Long name",
186 "Generic", "FIXME Description", "$REAL_NAME <$EMAIL_ADDRESS>");
190 gst_replace_class_init (GstReplaceClass * klass)
193 grep -A 10000 '^% declare-class' $templatedir/base | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
194 grep -A 10000 '^% declare-class' $templatedir/gobject | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
195 grep -A 10000 '^% declare-class' $templatedir/$class | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
199 grep -A 10000 '^% set-methods' $templatedir/base | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
200 grep -A 10000 '^% set-methods' $templatedir/gobject | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
201 grep -A 10000 '^% set-methods' $templatedir/$class | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
208 gst_replace_init (GstReplace * replace, GstReplaceClass * replace_class)
214 grep -A 10000 '^% instance-init' $templatedir/$each | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
223 grep -A 10000 '^% methods' $templatedir/base | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
224 grep -A 10000 '^% methods' $templatedir/gobject | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
225 grep -A 10000 '^% methods' $templatedir/$class | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
228 grep -A 10000 '^% methods' $templatedir/$each | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
235 plugin_init (GstPlugin * plugin)
238 gst_element_register (plugin, "replace", GST_RANK_NONE,
239 gst_replace_get_type ());
245 #define VERSION "0.0.FIXME"
248 #define PACKAGE "FIXME_package"
251 #define PACKAGE_NAME "FIXME_package_name"
253 #ifndef GST_PACKAGE_ORIGIN
254 #define GST_PACKAGE_ORIGIN "http://FIXME.org/"
257 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
260 "FIXME plugin description",
261 plugin_init, VERSION, "LGPL", PACKAGE_NAME, GST_PACKAGE_ORIGIN)
271 grep -A 10000 '^% copyright' $templatedir/base | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
274 #ifndef _GST_REPLACE_H_
275 #define _GST_REPLACE_H_
279 grep -A 10000 '^% includes' $templatedir/base | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
280 grep -A 10000 '^% includes' $templatedir/gobject | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
281 grep -A 10000 '^% includes' $templatedir/$class | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
287 #define GST_TYPE_REPLACE \
288 (gst_replace_get_type())
289 #define GST_REPLACE(obj) \
290 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_REPLACE,GstReplace))
291 #define GST_REPLACE_CLASS(klass) \
292 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_REPLACE,GstReplaceClass))
293 #define GST_IS_REPLACE(obj) \
294 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_REPLACE))
295 #define GST_IS_REPLACE_CLASS(obj) \
296 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_REPLACE))
298 typedef struct _GstReplace GstReplace;
299 typedef struct _GstReplaceClass GstReplaceClass;
303 GstBaseReplace base_replace;
309 grep -A 10000 '^% instance-members' $templatedir/$each | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
315 struct _GstReplaceClass
317 GstBaseReplaceClass base_replace_class;
320 GType gst_replace_get_type (void);
332 -e "s/GST_BASE_REPLACE/$GST_BASE_REPLACE/g" \
333 -e "s/GST_TYPE_BASE_REPLACE/$GST_TYPE_BASE_REPLACE/g" \
334 -e "s/GstBaseReplace/$GstBaseReplace/g" \
335 -e "s/GST_IS_REPLACE/$GST_IS_REPLACE/g" \
336 -e "s/GST_REPLACE/$GST_REPLACE/g" \
337 -e "s/GST_TYPE_REPLACE/$GST_TYPE_REPLACE/g" \
338 -e "s/GstReplace/$GstReplace/g" \
339 -e "s/gst_replace/$gst_replace/g" \
340 -e "s/gstreplace/$gstreplace/g" \
341 -e "s/replace/$replace/g" >$gstreplace.c
343 generate_header | sed \
344 -e "s/GST_BASE_REPLACE/$GST_BASE_REPLACE/g" \
345 -e "s/GST_TYPE_BASE_REPLACE/$GST_TYPE_BASE_REPLACE/g" \
346 -e "s/GstBaseReplace/$GstBaseReplace/g" \
347 -e "s/GST_IS_REPLACE/$GST_IS_REPLACE/g" \
348 -e "s/GST_REPLACE/$GST_REPLACE/g" \
349 -e "s/GST_TYPE_REPLACE/$GST_TYPE_REPLACE/g" \
350 -e "s/GstReplace/$GstReplace/g" \
351 -e "s/gst_replace/$gst_replace/g" \
352 -e "s/gstreplace/$gstreplace/g" \
353 -e "s/replace/$replace/g" >$gstreplace.h
355 gst-indent $gstreplace.c
359 gcc -Wall $(pkg-config --cflags gstreamer-0.10 $pkg) -c -o $gstreplace.o $gstreplace.c
360 gcc -shared -o $gstreplace.so $gstreplace.o $(pkg-config --libs gstreamer-0.10 $pkg)