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 GstBaseTransformClass *gstbasetrans_class;
109 gobject_class = G_OBJECT_CLASS (klass);
110 gstbasetrans_class = GST_BASE_TRANSFORM_CLASS (klass);
112 gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_mytoggle_set_property);
113 gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_mytoggle_get_property);
115 g_object_class_install_property (gobject_class,
116 PROP_BLOCK_DATA, g_param_spec_boolean ("block_data",
119 DEFAULT_BLOCK_DATA, G_PARAM_READWRITE));
121 gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_mytoggle_finalize);
123 gstbasetrans_class->event = GST_DEBUG_FUNCPTR (gst_mytoggle_event);
124 gstbasetrans_class->transform_ip =
125 GST_DEBUG_FUNCPTR (gst_mytoggle_transform_ip);
126 gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_mytoggle_start);
127 gstbasetrans_class->stop = GST_DEBUG_FUNCPTR (gst_mytoggle_stop);
131 gst_mytoggle_init (GstMytoggle * mytoggle, GstMytoggleClass * g_class)
133 gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (mytoggle), TRUE);
135 mytoggle->block_data = DEFAULT_BLOCK_DATA;
141 gst_mytoggle_event (GstBaseTransform * trans, GstEvent * event)
147 gst_mytoggle_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
149 GstMytoggle *mytoggle = GST_MYTOGGLE (trans);
151 if (mytoggle->block_data ==TRUE)
152 return GST_BASE_TRANSFORM_FLOW_DROPPED;
158 gst_mytoggle_set_property (GObject * object, guint prop_id,
159 const GValue * value, GParamSpec * pspec)
161 GstMytoggle *mytoggle;
163 mytoggle = GST_MYTOGGLE (object);
167 case PROP_BLOCK_DATA:
168 mytoggle->block_data = g_value_get_boolean (value);
171 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
177 gst_mytoggle_get_property (GObject * object, guint prop_id, GValue * value,
180 GstMytoggle *mytoggle;
182 mytoggle = GST_MYTOGGLE (object);
185 case PROP_BLOCK_DATA:
186 g_value_set_boolean (value, mytoggle->block_data);
189 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
195 gst_mytoggle_start (GstBaseTransform * trans)
201 gst_mytoggle_stop (GstBaseTransform * trans)
207 static gboolean plugin_init(GstPlugin *plugin)
210 GST_DEBUG_CATEGORY_INIT (gst_mytoggle_debug, "toggle",0, "toggle");
211 return gst_element_register (plugin, "toggle", GST_RANK_NONE, GST_TYPE_MYTOGGLE);
213 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
216 "Base transform plugin template",
217 plugin_init, VERSION, "LGPL", "Samsung Electronics Co", "http://www.samsung.com/")