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"
32 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
37 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
42 GST_DEBUG_CATEGORY_STATIC (gst_mytoggle_debug);
43 #define GST_CAT_DEFAULT gst_mytoggle_debug
51 #define DEFAULT_BLOCK_DATA FALSE
61 #define _do_init(bla) \
62 GST_DEBUG_CATEGORY_INIT (gst_mytoggle_debug, "toggle", 0, "toggle element");
64 G_DEFINE_TYPE_WITH_CODE (GstMytoggle, gst_mytoggle,
65 GST_TYPE_BASE_TRANSFORM, _do_init(G_TYPE_INVALID));
67 static void gst_mytoggle_finalize (GObject * object);
68 static void gst_mytoggle_set_property (GObject * object, guint prop_id,
69 const GValue * value, GParamSpec * pspec);
70 static void gst_mytoggle_get_property (GObject * object, guint prop_id,
71 GValue * value, GParamSpec * pspec);
73 static GstFlowReturn gst_mytoggle_transform_ip (GstBaseTransform * trans,
75 static gboolean gst_mytoggle_start (GstBaseTransform * trans);
76 static gboolean gst_mytoggle_stop (GstBaseTransform * trans);
79 gst_mytoggle_base_init (gpointer g_class)
84 gst_mytoggle_finalize (GObject * object)
86 GstMytoggle *mytoggle;
88 G_OBJECT_CLASS (gst_mytoggle_parent_class)->finalize (object);
92 gst_mytoggle_class_init (GstMytoggleClass * klass)
94 GObjectClass *gobject_class;
95 GstBaseTransformClass *gstbasetrans_class;
96 GstElementClass *gstelement_class;
98 gobject_class = G_OBJECT_CLASS (klass);
99 gstbasetrans_class = GST_BASE_TRANSFORM_CLASS (klass);
100 gstelement_class = GST_ELEMENT_CLASS (klass);
102 gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_mytoggle_set_property);
103 gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_mytoggle_get_property);
105 g_object_class_install_property (gobject_class,
106 PROP_BLOCK_DATA, g_param_spec_boolean ("block_data",
109 DEFAULT_BLOCK_DATA, G_PARAM_READWRITE));
111 gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_mytoggle_finalize);
113 gst_element_class_set_details_simple (gstelement_class,
116 "Pass data without modification", "Rahul Mittal <mittal.rahul@samsung.com>");
117 gst_element_class_add_pad_template (gstelement_class,
118 gst_static_pad_template_get (&srctemplate));
119 gst_element_class_add_pad_template (gstelement_class,
120 gst_static_pad_template_get (&sinktemplate));
122 gstbasetrans_class->transform_ip =
123 GST_DEBUG_FUNCPTR (gst_mytoggle_transform_ip);
124 gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_mytoggle_start);
125 gstbasetrans_class->stop = GST_DEBUG_FUNCPTR (gst_mytoggle_stop);
129 gst_mytoggle_init (GstMytoggle * mytoggle)
131 gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (mytoggle), TRUE);
133 mytoggle->block_data = DEFAULT_BLOCK_DATA;
138 gst_mytoggle_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
140 GstMytoggle *mytoggle = GST_MYTOGGLE (trans);
142 if (mytoggle->block_data ==TRUE)
143 return GST_BASE_TRANSFORM_FLOW_DROPPED;
149 gst_mytoggle_set_property (GObject * object, guint prop_id,
150 const GValue * value, GParamSpec * pspec)
152 GstMytoggle *mytoggle;
154 mytoggle = GST_MYTOGGLE (object);
158 case PROP_BLOCK_DATA:
159 mytoggle->block_data = g_value_get_boolean (value);
162 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
168 gst_mytoggle_get_property (GObject * object, guint prop_id, GValue * value,
171 GstMytoggle *mytoggle;
173 mytoggle = GST_MYTOGGLE (object);
176 case PROP_BLOCK_DATA:
177 g_value_set_boolean (value, mytoggle->block_data);
180 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
186 gst_mytoggle_start (GstBaseTransform * trans)
192 gst_mytoggle_stop (GstBaseTransform * trans)
198 static gboolean plugin_init(GstPlugin *plugin)
201 GST_DEBUG_CATEGORY_INIT (gst_mytoggle_debug, "toggle",0, "toggle");
202 return gst_element_register (plugin, "toggle", GST_RANK_NONE, GST_TYPE_MYTOGGLE);
204 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
207 "Base transform plugin template",
208 plugin_init, VERSION, "LGPL", "Samsung Electronics Co", "http://www.samsung.com/")