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 */
46 static void gst_navigationtest_base_init (gpointer g_class);
47 static void gst_navigationtest_class_init (gpointer g_class, gpointer class_data);
48 static void gst_navigationtest_init (GTypeInstance *instance, gpointer g_class);
50 static gboolean gst_navigationtest_handle_src_event (GstPad *pad, GstEvent *event);
51 static void gst_navigationtest_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
52 static void gst_navigationtest_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
54 static void gst_navigationtest_planar411(GstVideofilter *videofilter, void *dest, void *src);
55 static void gst_navigationtest_setup(GstVideofilter *videofilter);
58 gst_navigationtest_get_type (void)
60 static GType navigationtest_type = 0;
62 if (!navigationtest_type) {
63 static const GTypeInfo navigationtest_info = {
64 sizeof(GstNavigationtestClass),
65 gst_navigationtest_base_init,
67 gst_navigationtest_class_init,
70 sizeof(GstNavigationtest),
72 gst_navigationtest_init,
74 navigationtest_type = g_type_register_static(GST_TYPE_VIDEOFILTER,
75 "GstNavigationtest", &navigationtest_info, 0);
77 return navigationtest_type;
80 static GstVideofilterFormat gst_navigationtest_formats[] = {
81 { "I420", 12, gst_navigationtest_planar411, },
86 gst_navigationtest_base_init (gpointer g_class)
88 static GstElementDetails navigationtest_details = GST_ELEMENT_DETAILS (
89 "Video Filter Template",
91 "Template for a video filter",
92 "David Schleef <ds@schleef.org>"
94 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
95 GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
98 gst_element_class_set_details (element_class, &navigationtest_details);
100 for(i=0;i<G_N_ELEMENTS(gst_navigationtest_formats);i++){
101 gst_videofilter_class_add_format(videofilter_class,
102 gst_navigationtest_formats + i);
105 gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
109 gst_navigationtest_class_init (gpointer g_class, gpointer class_data)
111 GObjectClass *gobject_class;
112 GstVideofilterClass *videofilter_class;
114 gobject_class = G_OBJECT_CLASS (g_class);
115 videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
118 g_object_class_install_property(gobject_class, ARG_METHOD,
119 g_param_spec_enum("method","method","method",
120 GST_TYPE_NAVIGATIONTEST_METHOD, GST_NAVIGATIONTEST_METHOD_1,
124 gobject_class->set_property = gst_navigationtest_set_property;
125 gobject_class->get_property = gst_navigationtest_get_property;
127 videofilter_class->setup = gst_navigationtest_setup;
131 gst_navigationtest_init (GTypeInstance *instance, gpointer g_class)
133 GstNavigationtest *navigationtest = GST_NAVIGATIONTEST (instance);
134 GstVideofilter *videofilter;
136 GST_DEBUG("gst_navigationtest_init");
138 videofilter = GST_VIDEOFILTER(navigationtest);
140 gst_pad_set_event_function (videofilter->srcpad,
141 gst_navigationtest_handle_src_event);
143 navigationtest->x = -1;
144 navigationtest->y = -1;
148 gst_navigationtest_handle_src_event (GstPad *pad, GstEvent *event)
150 GstNavigationtest *navigationtest;
152 navigationtest = GST_NAVIGATIONTEST (gst_pad_get_parent (pad));
154 switch (GST_EVENT_TYPE (event)) {
155 case GST_EVENT_NAVIGATION:
156 gst_structure_get_double(event->event_data.structure.structure,
157 "pointer_x", &navigationtest->x);
158 gst_structure_get_double(event->event_data.structure.structure,
159 "pointer_y", &navigationtest->y);
168 gst_navigationtest_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
170 GstNavigationtest *src;
172 /* it's not null if we got it, but it might not be ours */
173 g_return_if_fail(GST_IS_NAVIGATIONTEST(object));
174 src = GST_NAVIGATIONTEST(object);
176 GST_DEBUG("gst_navigationtest_set_property");
180 src->method = g_value_get_enum (value);
189 gst_navigationtest_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
191 GstNavigationtest *src;
193 /* it's not null if we got it, but it might not be ours */
194 g_return_if_fail(GST_IS_NAVIGATIONTEST(object));
195 src = GST_NAVIGATIONTEST(object);
200 g_value_set_enum (value, src->method);
204 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
209 static gboolean plugin_init (GstPlugin *plugin)
211 if(!gst_library_load("gstvideofilter"))
214 return gst_element_register (plugin, "navigationtest", GST_RANK_NONE,
215 GST_TYPE_NAVIGATIONTEST);
222 "Template for a video filter",
230 static void gst_navigationtest_setup(GstVideofilter *videofilter)
232 GstNavigationtest *navigationtest;
234 g_return_if_fail(GST_IS_NAVIGATIONTEST(videofilter));
235 navigationtest = GST_NAVIGATIONTEST(videofilter);
237 /* if any setup needs to be done, do it here */
241 static void gst_navigationtest_planar411(GstVideofilter *videofilter,
242 void *dest, void *src)
244 GstNavigationtest *navigationtest;
245 int width = gst_videofilter_get_input_width(videofilter);
246 int height = gst_videofilter_get_input_height(videofilter);
250 g_return_if_fail(GST_IS_NAVIGATIONTEST(videofilter));
251 navigationtest = GST_NAVIGATIONTEST(videofilter);
253 /* do something interesting here. This simply copies the source
254 * to the destination. */
255 memcpy(dest,src,width * height + (width/2) * (height/2) * 2);
257 x = rint(navigationtest->x);
258 y = rint(navigationtest->y);
260 if(x<0 || y<0 || x>=width || y>=height)return;
263 x2 = MIN(x+5, width);
265 y2 = MIN(y+5, height);
269 ((guint8 *)dest)[y*width + x] = 0;
273 dest += height*width;
282 ((guint8 *)dest)[y*width + x] = 128;
286 dest += height*width;
289 ((guint8 *)dest)[y*width + x] = 128;