|
1 /* GStreamer |
|
2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> |
|
3 * Copyright (C) <2003> David Schleef <ds@schleef.org> |
|
4 * |
|
5 * This library is free software; you can redistribute it and/or |
|
6 * modify it under the terms of the GNU Library General Public |
|
7 * License as published by the Free Software Foundation; either |
|
8 * version 2 of the License, or (at your option) any later version. |
|
9 * |
|
10 * This library is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 * Library General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU Library General Public |
|
16 * License along with this library; if not, write to the |
|
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
18 * Boston, MA 02111-1307, USA. |
|
19 */ |
|
20 |
|
21 /* |
|
22 * This file was (probably) generated from |
|
23 * gstaudiofiltertemplate.c,v 1.14 2007-02-03 23:28:45 tpm Exp |
|
24 * and |
|
25 * $Id: make_filter,v 1.3 2004-04-19 22:51:56 ds Exp $ |
|
26 */ |
|
27 |
|
28 #ifdef HAVE_CONFIG_H |
|
29 #include "config.h" |
|
30 #endif |
|
31 |
|
32 #include <gst/gst.h> |
|
33 #include <gst/audio/audio.h> |
|
34 #include <gst/audio/gstaudiofilter.h> |
|
35 #include <string.h> |
|
36 |
|
37 GST_DEBUG_CATEGORY_STATIC (audio_filter_template_debug); |
|
38 #define GST_CAT_DEFAULT audio_filter_template_debug |
|
39 |
|
40 static const GstElementDetails audio_filter_template_details = |
|
41 GST_ELEMENT_DETAILS ("Audio filter template", |
|
42 "Filter/Effect/Audio", |
|
43 "Filters audio", |
|
44 "David Schleef <ds@schleef.org>"); |
|
45 |
|
46 typedef struct _GstAudioFilterTemplate GstAudioFilterTemplate; |
|
47 typedef struct _GstAudioFilterTemplateClass GstAudioFilterTemplateClass; |
|
48 |
|
49 #define GST_TYPE_AUDIO_FILTER_TEMPLATE \ |
|
50 (gst_audio_filter_template_get_type()) |
|
51 #define GST_AUDIO_FILTER_TEMPLATE(obj) \ |
|
52 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIO_FILTER_TEMPLATE,GstAudioFilterTemplate)) |
|
53 #define GST_AUDIO_FILTER_TEMPLATE_CLASS(klass) \ |
|
54 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIO_FILTER_TEMPLATE,GstAudioFilterTemplateClass)) |
|
55 #define GST_IS_AUDIO_FILTER_TEMPLATE(obj) \ |
|
56 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_FILTER_TEMPLATE)) |
|
57 #define GST_IS_AUDIO_FILTER_TEMPLATE_CLASS(klass) \ |
|
58 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_FILTER_TEMPLATE)) |
|
59 |
|
60 struct _GstAudioFilterTemplate |
|
61 { |
|
62 GstAudioFilter audiofilter; |
|
63 }; |
|
64 |
|
65 struct _GstAudioFilterTemplateClass |
|
66 { |
|
67 GstAudioFilterClass parent_class; |
|
68 }; |
|
69 |
|
70 |
|
71 enum |
|
72 { |
|
73 /* FILL ME */ |
|
74 LAST_SIGNAL |
|
75 }; |
|
76 |
|
77 enum |
|
78 { |
|
79 ARG_0 |
|
80 /* FILL ME */ |
|
81 }; |
|
82 |
|
83 GST_BOILERPLATE (GstAudioFilterTemplate, gst_audio_filter_template, |
|
84 GstAudioFilter, GST_TYPE_AUDIO_FILTER); |
|
85 |
|
86 static void gst_audio_filter_template_set_property (GObject * object, |
|
87 guint prop_id, const GValue * value, GParamSpec * pspec); |
|
88 static void gst_audio_filter_template_get_property (GObject * object, |
|
89 guint prop_id, GValue * value, GParamSpec * pspec); |
|
90 |
|
91 static gboolean gst_audio_filter_template_setup (GstAudioFilter * filter, |
|
92 GstRingBufferSpec * spec); |
|
93 static GstFlowReturn gst_audio_filter_template_filter (GstBaseTransform * bt, |
|
94 GstBuffer * outbuf, GstBuffer * inbuf); |
|
95 static GstFlowReturn |
|
96 gst_audio_filter_template_filter_inplace (GstBaseTransform * base_transform, |
|
97 GstBuffer * buf); |
|
98 |
|
99 #define ALLOWED_CAPS_STRING \ |
|
100 GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS |
|
101 |
|
102 static void |
|
103 gst_audio_filter_template_base_init (gpointer g_class) |
|
104 { |
|
105 GstAudioFilterTemplateClass *klass = (GstAudioFilterTemplateClass *) g_class; |
|
106 GstAudioFilterClass *audiofilter_class = GST_AUDIO_FILTER_CLASS (g_class); |
|
107 GstElementClass *element_class = GST_ELEMENT_CLASS (klass); |
|
108 GstCaps *caps; |
|
109 |
|
110 gst_element_class_set_details (element_class, &audio_filter_template_details); |
|
111 |
|
112 caps = gst_caps_from_string (ALLOWED_CAPS_STRING); |
|
113 gst_audio_filter_class_add_pad_templates (audiofilter_class, caps); |
|
114 gst_caps_unref (caps); |
|
115 } |
|
116 |
|
117 static void |
|
118 gst_audio_filter_template_class_init (GstAudioFilterTemplateClass * klass) |
|
119 { |
|
120 GObjectClass *gobject_class; |
|
121 GstBaseTransformClass *btrans_class; |
|
122 GstAudioFilterClass *audio_filter_class; |
|
123 |
|
124 gobject_class = (GObjectClass *) klass; |
|
125 btrans_class = (GstBaseTransformClass *) klass; |
|
126 audio_filter_class = (GstAudioFilterClass *) klass; |
|
127 |
|
128 #if 0 |
|
129 g_object_class_install_property (gobject_class, ARG_METHOD, |
|
130 g_param_spec_enum ("method", "method", "method", |
|
131 GST_TYPE_AUDIOTEMPLATE_METHOD, GST_AUDIOTEMPLATE_METHOD_1, |
|
132 G_PARAM_READWRITE)); |
|
133 #endif |
|
134 |
|
135 gobject_class->set_property = gst_audio_filter_template_set_property; |
|
136 gobject_class->get_property = gst_audio_filter_template_get_property; |
|
137 |
|
138 /* this function will be called whenever the format changes */ |
|
139 audio_filter_class->setup = gst_audio_filter_template_setup; |
|
140 |
|
141 /* here you set up functions to process data (either in place, or from |
|
142 * one input buffer to another output buffer); only one is required */ |
|
143 btrans_class->transform = gst_audio_filter_template_filter; |
|
144 btrans_class->transform_ip = gst_audio_filter_template_filter_inplace; |
|
145 } |
|
146 |
|
147 static void |
|
148 gst_audio_filter_template_init (GstAudioFilterTemplate * audio_filter_template, |
|
149 GstAudioFilterTemplateClass * g_class) |
|
150 { |
|
151 GST_DEBUG ("init"); |
|
152 |
|
153 /* do stuff if you need to */ |
|
154 } |
|
155 |
|
156 static void |
|
157 gst_audio_filter_template_set_property (GObject * object, guint prop_id, |
|
158 const GValue * value, GParamSpec * pspec) |
|
159 { |
|
160 GstAudioFilterTemplate *filter; |
|
161 |
|
162 filter = GST_AUDIO_FILTER_TEMPLATE (object); |
|
163 |
|
164 GST_DEBUG ("set property %u", prop_id); |
|
165 |
|
166 GST_OBJECT_LOCK (filter); |
|
167 switch (prop_id) { |
|
168 default: |
|
169 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
|
170 break; |
|
171 } |
|
172 GST_OBJECT_UNLOCK (filter); |
|
173 } |
|
174 |
|
175 static void |
|
176 gst_audio_filter_template_get_property (GObject * object, guint prop_id, |
|
177 GValue * value, GParamSpec * pspec) |
|
178 { |
|
179 GstAudioFilterTemplate *filter; |
|
180 |
|
181 filter = GST_AUDIO_FILTER_TEMPLATE (object); |
|
182 |
|
183 GST_DEBUG ("get property %u", prop_id); |
|
184 |
|
185 GST_OBJECT_LOCK (filter); |
|
186 switch (prop_id) { |
|
187 default: |
|
188 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
|
189 break; |
|
190 } |
|
191 GST_OBJECT_UNLOCK (filter); |
|
192 } |
|
193 |
|
194 static gboolean |
|
195 gst_audio_filter_template_setup (GstAudioFilter * filter, |
|
196 GstRingBufferSpec * spec) |
|
197 { |
|
198 GstAudioFilterTemplate *audio_filter_template; |
|
199 |
|
200 audio_filter_template = GST_AUDIO_FILTER_TEMPLATE (filter); |
|
201 |
|
202 /* if any setup needs to be done, do it here */ |
|
203 |
|
204 return TRUE; /* it's all good */ |
|
205 } |
|
206 |
|
207 /* You may choose to implement either a copying filter or an |
|
208 * in-place filter (or both). Implementing only one will give |
|
209 * full functionality, however, implementing both will cause |
|
210 * audiofilter to use the optimal function in every situation, |
|
211 * with a minimum of memory copies. */ |
|
212 |
|
213 static GstFlowReturn |
|
214 gst_audio_filter_template_filter (GstBaseTransform * base_transform, |
|
215 GstBuffer * inbuf, GstBuffer * outbuf) |
|
216 { |
|
217 GstAudioFilterTemplate *audio_filter_template; |
|
218 GstAudioFilter *audiofilter; |
|
219 |
|
220 audiofilter = GST_AUDIO_FILTER (base_transform); |
|
221 audio_filter_template = GST_AUDIO_FILTER_TEMPLATE (base_transform); |
|
222 |
|
223 /* do something interesting here. This simply copies the source |
|
224 * to the destination. */ |
|
225 |
|
226 memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf), |
|
227 GST_BUFFER_SIZE (inbuf)); |
|
228 |
|
229 return GST_FLOW_OK; |
|
230 } |
|
231 |
|
232 static GstFlowReturn |
|
233 gst_audio_filter_template_filter_inplace (GstBaseTransform * base_transform, |
|
234 GstBuffer * buf) |
|
235 { |
|
236 GstAudioFilterTemplate *audio_filter_template; |
|
237 GstAudioFilter *audiofilter; |
|
238 |
|
239 audiofilter = GST_AUDIO_FILTER (base_transform); |
|
240 audio_filter_template = GST_AUDIO_FILTER_TEMPLATE (base_transform); |
|
241 |
|
242 /* do something interesting here. This simply copies the source |
|
243 * to the destination. */ |
|
244 |
|
245 return GST_FLOW_OK; |
|
246 } |
|
247 |
|
248 static gboolean |
|
249 plugin_init (GstPlugin * plugin) |
|
250 { |
|
251 GST_DEBUG_CATEGORY_INIT (audio_filter_template_debug, "audiofilterexample", |
|
252 0, "audiofilterexample"); |
|
253 |
|
254 return gst_element_register (plugin, "audiofilterexample", GST_RANK_NONE, |
|
255 GST_TYPE_AUDIO_FILTER_TEMPLATE); |
|
256 } |
|
257 |
|
258 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, |
|
259 GST_VERSION_MINOR, |
|
260 "gstaudio_filter_template", |
|
261 "Audio filter template", |
|
262 plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN); |