4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>
8 * This library is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU Lesser General Public License as published by the
10 * Free Software Foundation; either version 2.1 of the License, or (at your option)
13 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 * License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library; if not, write to the Free Software Foundation, Inc., 51
20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 #include "gsttoggle.h"
31 #include <gst/gstmarshal.h>
33 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
38 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
43 GST_DEBUG_CATEGORY_STATIC (gst_mytoggle_debug);
44 #define GST_CAT_DEFAULT gst_mytoggle_debug
52 #define DEFAULT_BLOCK_DATA FALSE
62 #define _do_init(bla) \
63 GST_DEBUG_CATEGORY_INIT (gst_mytoggle_debug, "toggle", 0, "toggle element");
65 GST_BOILERPLATE_FULL (GstMytoggle, gst_mytoggle, GstBaseTransform,
66 GST_TYPE_BASE_TRANSFORM, _do_init);
68 static void gst_mytoggle_finalize (GObject * object);
69 static void gst_mytoggle_set_property (GObject * object, guint prop_id,
70 const GValue * value, GParamSpec * pspec);
71 static void gst_mytoggle_get_property (GObject * object, guint prop_id,
72 GValue * value, GParamSpec * pspec);
74 static gboolean gst_mytoggle_event (GstBaseTransform * trans, GstEvent * event);
75 static GstFlowReturn gst_mytoggle_transform_ip (GstBaseTransform * trans,
77 static gboolean gst_mytoggle_start (GstBaseTransform * trans);
78 static gboolean gst_mytoggle_stop (GstBaseTransform * trans);
81 gst_mytoggle_base_init (gpointer g_class)
83 GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
85 gst_element_class_set_details_simple (gstelement_class,
88 "Pass data without modification", "Rahul Mittal <mittal.rahul@samsung.com>");
89 gst_element_class_add_pad_template (gstelement_class,
90 gst_static_pad_template_get (&srctemplate));
91 gst_element_class_add_pad_template (gstelement_class,
92 gst_static_pad_template_get (&sinktemplate));
96 gst_mytoggle_finalize (GObject * object)
98 GstMytoggle *mytoggle;
100 G_OBJECT_CLASS (parent_class)->finalize (object);
104 gst_mytoggle_class_init (GstMytoggleClass * klass)
106 GObjectClass *gobject_class;
107 GstElementClass *gstelement_class;
108 GstBaseTransformClass *gstbasetrans_class;
110 gobject_class = G_OBJECT_CLASS (klass);
111 gstelement_class = GST_ELEMENT_CLASS (klass);
112 gstbasetrans_class = GST_BASE_TRANSFORM_CLASS (klass);
114 gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_mytoggle_set_property);
115 gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_mytoggle_get_property);
117 g_object_class_install_property (gobject_class,
118 PROP_BLOCK_DATA, g_param_spec_boolean ("block_data",
121 DEFAULT_BLOCK_DATA, G_PARAM_READWRITE));
123 gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_mytoggle_finalize);
125 gstbasetrans_class->event = GST_DEBUG_FUNCPTR (gst_mytoggle_event);
126 gstbasetrans_class->transform_ip =
127 GST_DEBUG_FUNCPTR (gst_mytoggle_transform_ip);
128 gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_mytoggle_start);
129 gstbasetrans_class->stop = GST_DEBUG_FUNCPTR (gst_mytoggle_stop);
133 gst_mytoggle_init (GstMytoggle * mytoggle, GstMytoggleClass * g_class)
135 gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (mytoggle), TRUE);
137 mytoggle->block_data = DEFAULT_BLOCK_DATA;
143 gst_mytoggle_event (GstBaseTransform * trans, GstEvent * event)
149 gst_mytoggle_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
151 GstMytoggle *mytoggle = GST_MYTOGGLE (trans);
153 if (mytoggle->block_data ==TRUE)
154 return GST_BASE_TRANSFORM_FLOW_DROPPED;
160 gst_mytoggle_set_property (GObject * object, guint prop_id,
161 const GValue * value, GParamSpec * pspec)
163 GstMytoggle *mytoggle;
165 mytoggle = GST_MYTOGGLE (object);
169 case PROP_BLOCK_DATA:
170 mytoggle->block_data = g_value_get_boolean (value);
173 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
179 gst_mytoggle_get_property (GObject * object, guint prop_id, GValue * value,
182 GstMytoggle *mytoggle;
184 mytoggle = GST_MYTOGGLE (object);
187 case PROP_BLOCK_DATA:
188 g_value_set_boolean (value, mytoggle->block_data);
191 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
197 gst_mytoggle_start (GstBaseTransform * trans)
203 gst_mytoggle_stop (GstBaseTransform * trans)
209 static gboolean plugin_init(GstPlugin *plugin)
212 GST_DEBUG_CATEGORY_INIT (gst_mytoggle_debug, "toggle",0, "toggle");
213 return gst_element_register (plugin, "toggle", GST_RANK_NONE, GST_TYPE_MYTOGGLE);
215 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
218 "Base transform plugin template",
219 plugin_init, VERSION, "LGPL", "Samsung Electronics Co", "http://www.samsung.com/")