2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) <2003> David Schleef <ds@schleef.org>
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.
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.
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.
22 * This file was (probably) generated from gstnavigationtest.c,
23 * gstnavigationtest.c,v 1.7 2003/11/08 02:48:59 dschleef Exp
30 /*#define DEBUG_ENABLED */
31 #include <gstnavigationtest.h>
35 /* GstNavigationtest signals and args */
48 static void gst_navigationtest_base_init (gpointer g_class);
49 static void gst_navigationtest_class_init (gpointer g_class,
51 static void gst_navigationtest_init (GTypeInstance * instance,
54 static gboolean gst_navigationtest_handle_src_event (GstPad * pad,
56 static void gst_navigationtest_set_property (GObject * object, guint prop_id,
57 const GValue * value, GParamSpec * pspec);
58 static void gst_navigationtest_get_property (GObject * object, guint prop_id,
59 GValue * value, GParamSpec * pspec);
61 static void gst_navigationtest_planar411 (GstVideofilter * videofilter,
62 void *dest, void *src);
63 static void gst_navigationtest_setup (GstVideofilter * videofilter);
66 gst_navigationtest_get_type (void)
68 static GType navigationtest_type = 0;
70 if (!navigationtest_type) {
71 static const GTypeInfo navigationtest_info = {
72 sizeof (GstNavigationtestClass),
73 gst_navigationtest_base_init,
75 gst_navigationtest_class_init,
78 sizeof (GstNavigationtest),
80 gst_navigationtest_init,
83 navigationtest_type = g_type_register_static (GST_TYPE_VIDEOFILTER,
84 "GstNavigationtest", &navigationtest_info, 0);
86 return navigationtest_type;
89 static GstVideofilterFormat gst_navigationtest_formats[] = {
90 {"I420", 12, gst_navigationtest_planar411,},
95 gst_navigationtest_base_init (gpointer g_class)
97 static GstElementDetails navigationtest_details =
98 GST_ELEMENT_DETAILS ("Video Filter Template",
100 "Template for a video filter",
101 "David Schleef <ds@schleef.org>");
102 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
103 GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
106 gst_element_class_set_details (element_class, &navigationtest_details);
108 for (i = 0; i < G_N_ELEMENTS (gst_navigationtest_formats); i++) {
109 gst_videofilter_class_add_format (videofilter_class,
110 gst_navigationtest_formats + i);
113 gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
117 gst_navigationtest_class_init (gpointer g_class, gpointer class_data)
119 GObjectClass *gobject_class;
120 GstVideofilterClass *videofilter_class;
122 gobject_class = G_OBJECT_CLASS (g_class);
123 videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
126 g_object_class_install_property (gobject_class, ARG_METHOD,
127 g_param_spec_enum ("method", "method", "method",
128 GST_TYPE_NAVIGATIONTEST_METHOD, GST_NAVIGATIONTEST_METHOD_1,
132 gobject_class->set_property = gst_navigationtest_set_property;
133 gobject_class->get_property = gst_navigationtest_get_property;
135 videofilter_class->setup = gst_navigationtest_setup;
139 gst_navigationtest_init (GTypeInstance * instance, gpointer g_class)
141 GstNavigationtest *navigationtest = GST_NAVIGATIONTEST (instance);
142 GstVideofilter *videofilter;
144 GST_DEBUG ("gst_navigationtest_init");
146 videofilter = GST_VIDEOFILTER (navigationtest);
148 gst_pad_set_event_function (videofilter->srcpad,
149 gst_navigationtest_handle_src_event);
151 navigationtest->x = -1;
152 navigationtest->y = -1;
156 gst_navigationtest_handle_src_event (GstPad * pad, GstEvent * event)
158 GstNavigationtest *navigationtest;
160 navigationtest = GST_NAVIGATIONTEST (gst_pad_get_parent (pad));
162 switch (GST_EVENT_TYPE (event)) {
163 case GST_EVENT_NAVIGATION:
164 gst_structure_get_double (event->event_data.structure.structure,
165 "pointer_x", &navigationtest->x);
166 gst_structure_get_double (event->event_data.structure.structure,
167 "pointer_y", &navigationtest->y);
176 gst_navigationtest_set_property (GObject * object, guint prop_id,
177 const GValue * value, GParamSpec * pspec)
179 GstNavigationtest *src;
181 /* it's not null if we got it, but it might not be ours */
182 g_return_if_fail (GST_IS_NAVIGATIONTEST (object));
183 src = GST_NAVIGATIONTEST (object);
185 GST_DEBUG ("gst_navigationtest_set_property");
189 src->method = g_value_get_enum (value);
198 gst_navigationtest_get_property (GObject * object, guint prop_id,
199 GValue * value, GParamSpec * pspec)
201 GstNavigationtest *src;
203 /* it's not null if we got it, but it might not be ours */
204 g_return_if_fail (GST_IS_NAVIGATIONTEST (object));
205 src = GST_NAVIGATIONTEST (object);
210 g_value_set_enum (value, src->method);
214 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
220 plugin_init (GstPlugin * plugin)
222 if (!gst_library_load ("gstvideofilter"))
225 return gst_element_register (plugin, "navigationtest", GST_RANK_NONE,
226 GST_TYPE_NAVIGATIONTEST);
229 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
232 "Template for a video filter",
233 plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
235 static void gst_navigationtest_setup (GstVideofilter * videofilter)
237 GstNavigationtest *navigationtest;
239 g_return_if_fail (GST_IS_NAVIGATIONTEST (videofilter));
240 navigationtest = GST_NAVIGATIONTEST (videofilter);
242 /* if any setup needs to be done, do it here */
247 gst_navigationtest_planar411 (GstVideofilter * videofilter,
248 void *dest, void *src)
250 GstNavigationtest *navigationtest;
251 int width = gst_videofilter_get_input_width (videofilter);
252 int height = gst_videofilter_get_input_height (videofilter);
256 g_return_if_fail (GST_IS_NAVIGATIONTEST (videofilter));
257 navigationtest = GST_NAVIGATIONTEST (videofilter);
259 /* do something interesting here. This simply copies the source
260 * to the destination. */
261 memcpy (dest, src, width * height + (width / 2) * (height / 2) * 2);
263 x = rint (navigationtest->x);
264 y = rint (navigationtest->y);
266 if (x < 0 || y < 0 || x >= width || y >= height)
270 x2 = MIN (x + 5, width);
272 y2 = MIN (y + 5, height);
274 for (y = y1; y < y2; y++) {
275 for (x = x1; x < x2; x++) {
276 ((guint8 *) dest)[y * width + x] = 0;
280 dest += height * width;
287 for (y = y1; y < y2; y++) {
288 for (x = x1; x < x2; x++) {
289 ((guint8 *) dest)[y * width + x] = 128;
293 dest += height * width;
294 for (y = y1; y < y2; y++) {
295 for (x = x1; x < x2; x++) {
296 ((guint8 *) dest)[y * width + x] = 128;