10 Usage: element-maker [OPTIONS] ELEMENT_NAME BASE_CLASS
11 Create a GStreamer element that subclasses BASE_CLASS.
13 --help Print this information
14 --prefix PREFIX Use PREFIX instead of "gst"
15 Example: 'element-maker my_element basetransform' will create the files
16 gstmyelement.c and gstmyelement.h that implement GstMyElement, a
17 subclass of GstBaseTransform, as an element named myelement.
26 echo Unknown option: $1
30 if [ "$name" = "" ]; then
32 elif [ "$class" = "" ]; then
41 if [ "$name" = "" -o "$class" = "" ] ; then
42 echo "Usage: element-maker [OPTIONS] ELEMENT_NAME BASE_CLASS"
46 if [ ! -f "gst$class.c" ] ; then
47 echo "Template file for $class not found."
52 PREFIX=$(echo $prefix | sed -e 's/\(.*\)/\U\1/')
53 NAME=$(echo $name | sed -e 's/\(.*\)/\U\1/')
54 Prefix=$(echo $prefix | sed -e 's/_\(.\)/\U\1/' -e 's/^\(.\)/\U\1/')
55 Name=$(echo $name | sed -e 's/_\(.\)/\U\1/' -e 's/^\(.\)/\U\1/')
57 GST_IS_REPLACE=${PREFIX}_IS_${NAME}
58 GST_REPLACE=${PREFIX}_${NAME}
59 GST_TYPE_REPLACE=${PREFIX}_TYPE_${NAME}
60 GstReplace=${Prefix}${Name}
61 gst_replace=${prefix}_${name}
62 gstreplace=${prefix}$(echo $name | sed -e 's/_//')
63 replace=$(echo $name | sed -e 's/_//')
65 if [ "$REAL_NAME" = "" ] ; then
68 if [ "$EMAIL_ADDRESS" = "" ] ; then
69 EMAIL_ADDRESS=fixme@example.com
73 pkg=`grep -A 10000 '^% pkg-config' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1`
74 GST_TYPE_BASE_REPLACE=`grep -A 10000 '^% TYPE_CLASS_NAME' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1`
75 GstBaseReplace=`grep -A 10000 '^% ClassName' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1`
82 * Copyright (C) $(date +%Y) $REAL_NAME <$EMAIL_ADDRESS>
84 * This library is free software; you can redistribute it and/or
85 * modify it under the terms of the GNU Library General Public
86 * License as published by the Free Software Foundation; either
87 * version 2 of the License, or (at your option) any later version.
89 * This library is distributed in the hope that it will be useful,
90 * but WITHOUT ANY WARRANTY; without even the implied warranty of
91 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
92 * Library General Public License for more details.
94 * You should have received a copy of the GNU Library General Public
95 * License along with this library; if not, write to the
96 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
97 * Boston, MA 02111-1307, USA.
103 * SECTION:element-$gstreplace
105 * The $gstreplace element does FIXME stuff.
108 * <title>Example launch line</title>
110 * gst-launch -v fakesrc ! $gstreplace ! FIXME ! fakesink
112 * FIXME Describe what the pipeline does.
117 #grep -A 10000 '^% copyright' base.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
127 grep -A 10000 '^% includes' base.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
128 grep -A 10000 '^% includes' gobject.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
129 grep -A 10000 '^% includes' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
132 #include "gstreplace.h"
138 grep -A 10000 '^% prototypes' base.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
139 grep -A 10000 '^% prototypes' gobject.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
140 grep -A 10000 '^% prototypes' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
151 static GstStaticPadTemplate gst_replace_sink_template =
152 GST_STATIC_PAD_TEMPLATE ("sink",
155 GST_STATIC_CAPS ("application/unknown")
158 static GstStaticPadTemplate gst_replace_src_template =
159 GST_STATIC_PAD_TEMPLATE ("src",
162 GST_STATIC_CAPS ("application/unknown")
165 /* class initialization */
167 GST_BOILERPLATE (GstReplace, gst_replace, GstBaseReplace,
168 GST_TYPE_BASE_REPLACE);
171 gst_replace_base_init (gpointer g_class)
173 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
175 gst_element_class_add_pad_template (element_class,
176 gst_static_pad_template_get (&gst_replace_src_template));
177 gst_element_class_add_pad_template (element_class,
178 gst_static_pad_template_get (&gst_replace_sink_template));
180 gst_element_class_set_details_simple (element_class, "FIXME",
181 "Generic", "FIXME", "$REAL_NAME <$EMAIL_ADDRESS>");
185 gst_replace_class_init (GstReplaceClass * klass)
188 grep -A 10000 '^% declare-class' base.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
189 grep -A 10000 '^% declare-class' gobject.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
190 grep -A 10000 '^% declare-class' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
194 grep -A 10000 '^% set-methods' base.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
195 grep -A 10000 '^% set-methods' gobject.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
196 grep -A 10000 '^% set-methods' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
203 gst_replace_init (GstReplace * replace, GstReplaceClass * replace_class)
210 grep -A 10000 '^% methods' base.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
211 grep -A 10000 '^% methods' gobject.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
212 grep -A 10000 '^% methods' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
218 plugin_init (GstPlugin * plugin)
221 gst_element_register (plugin, "replace", GST_RANK_NONE,
222 gst_replace_get_type ());
227 #define VERSION "0.0.FIXME"
228 #define PACKAGE "FIXME_package"
229 #define PACKAGE_NAME "FIXME_package_name"
230 #define PACKAGE_ORIGIN "http://FIXME.org/"
232 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
236 plugin_init, VERSION, "LGPL", PACKAGE_NAME, PACKAGE_ORIGIN)
246 grep -A 10000 '^% copyright' base.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
249 #ifndef _GST_REPLACE_H_
250 #define _GST_REPLACE_H_
254 grep -A 10000 '^% includes' base.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
255 grep -A 10000 '^% includes' gobject.c | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
256 grep -A 10000 '^% includes' $source | tail -n +2|grep -m 1 -B 10000 '^%'|head -n -1
262 #define GST_TYPE_REPLACE \
263 (gst_replace_get_type())
264 #define GST_REPLACE(obj) \
265 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_REPLACE,GstReplace))
266 #define GST_REPLACE_CLASS(klass) \
267 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_REPLACE,GstReplaceClass))
268 #define GST_IS_REPLACE(obj) \
269 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_REPLACE))
270 #define GST_IS_REPLACE_CLASS(obj) \
271 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_REPLACE))
273 typedef struct _GstReplace GstReplace;
274 typedef struct _GstReplaceClass GstReplaceClass;
278 GstBaseReplace base_replace;
282 struct _GstReplaceClass
284 GstBaseReplaceClass base_replace_class;
287 GType gst_replace_get_type (void);
299 -e "s/GST_BASE_REPLACE/$GST_BASE_REPLACE/g" \
300 -e "s/GST_TYPE_BASE_REPLACE/$GST_TYPE_BASE_REPLACE/g" \
301 -e "s/GstBaseReplace/$GstBaseReplace/g" \
302 -e "s/GST_IS_REPLACE/$GST_IS_REPLACE/g" \
303 -e "s/GST_REPLACE/$GST_REPLACE/g" \
304 -e "s/GST_TYPE_REPLACE/$GST_TYPE_REPLACE/g" \
305 -e "s/GstReplace/$GstReplace/g" \
306 -e "s/gst_replace/$gst_replace/g" \
307 -e "s/gstreplace/$gstreplace/g" \
308 -e "s/replace/$replace/g" >$gstreplace.c
310 generate_header | sed \
311 -e "s/GST_BASE_REPLACE/$GST_BASE_REPLACE/g" \
312 -e "s/GST_TYPE_BASE_REPLACE/$GST_TYPE_BASE_REPLACE/g" \
313 -e "s/GstBaseReplace/$GstBaseReplace/g" \
314 -e "s/GST_IS_REPLACE/$GST_IS_REPLACE/g" \
315 -e "s/GST_REPLACE/$GST_REPLACE/g" \
316 -e "s/GST_TYPE_REPLACE/$GST_TYPE_REPLACE/g" \
317 -e "s/GstReplace/$GstReplace/g" \
318 -e "s/gst_replace/$gst_replace/g" \
319 -e "s/gstreplace/$gstreplace/g" \
320 -e "s/replace/$replace/g" >$gstreplace.h
322 gst-indent $gstreplace.c
326 gcc -Wall $(pkg-config --cflags gstreamer-0.10 $pkg) -c -o $gstreplace.o $gstreplace.c
327 gcc -shared -o $gstreplace.so $gstreplace.o $(pkg-config --libs gstreamer-0.10 $pkg)