2 * Farsight Voice+Video library
4 * Copyright 2007 Collabora Ltd,
5 * Copyright 2007 Nokia Corporation
6 * @author: Olivier Crete <olivier.crete@collabora.co.uk>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
33 GST_DEBUG_CATEGORY (valve_debug);
34 #define GST_CAT_DEFAULT (valve_debug)
36 /* elementfactory information */
37 static const GstElementDetails gst_valve_details =
41 "This element drops all packets when drop is TRUE",
42 "Olivier Crete <olivier.crete@collabora.co.uk>");
45 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
50 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
55 /* Valve signals and args */
71 static void gst_valve_set_property (GObject *object,
72 guint prop_id, const GValue * value, GParamSpec * pspec);
73 static void gst_valve_get_property (GObject *object,
74 guint prop_id, GValue *value, GParamSpec *pspec);
75 static void gst_valve_dispose (GObject *object);
78 gst_valve_transform_ip (GstBaseTransform *trans, GstBuffer *buf);
80 gst_valve_event (GstBaseTransform *trans, GstEvent *event);
86 GST_DEBUG_CATEGORY_INIT
87 (valve_debug, "valve", 0, "Valve");
90 GST_BOILERPLATE_FULL (GstValve, gst_valve, GstBaseTransform,
91 GST_TYPE_BASE_TRANSFORM, _do_init);
94 gst_valve_base_init (gpointer klass)
96 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
98 gst_element_class_add_pad_template (element_class,
99 gst_static_pad_template_get (&srctemplate));
100 gst_element_class_add_pad_template (element_class,
101 gst_static_pad_template_get (&sinktemplate));
103 gst_element_class_set_details (element_class, &gst_valve_details);
107 gst_valve_class_init (GstValveClass *klass)
109 GObjectClass *gobject_class;
110 GstBaseTransformClass *gstbasetransform_class;
112 gobject_class = (GObjectClass *) klass;
113 gstbasetransform_class = (GstBaseTransformClass *) klass;
115 gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_valve_dispose);
117 gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_valve_set_property);
118 gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_valve_get_property);
120 gstbasetransform_class->transform_ip =
121 GST_DEBUG_FUNCPTR (gst_valve_transform_ip);
122 gstbasetransform_class->event =
123 GST_DEBUG_FUNCPTR (gst_valve_event);
124 gstbasetransform_class->src_event =
125 GST_DEBUG_FUNCPTR (gst_valve_event);
127 g_object_class_install_property (gobject_class, ARG_DROP,
128 g_param_spec_boolean ("drop",
129 "Drops all buffers if TRUE",
130 "If this property if TRUE, the element will drop all buffers, if its FALSE, it will let them through",
131 FALSE, G_PARAM_READWRITE));
133 parent_class = g_type_class_peek_parent (klass);
137 gst_valve_init (GstValve *valve,
138 GstValveClass *klass)
143 gst_base_transform_set_passthrough ((GstBaseTransform *)valve, TRUE);
148 gst_valve_dispose (GObject *object)
150 GstValve *valve = NULL;
151 valve = GST_VALVE (valve);
153 G_OBJECT_CLASS (parent_class)->dispose (object);
158 gst_valve_set_property (GObject *object,
159 guint prop_id, const GValue *value, GParamSpec *pspec)
161 GstValve *valve = GST_VALVE (object);
165 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
168 GST_OBJECT_LOCK (object);
169 valve->drop = g_value_get_boolean (value);
170 GST_OBJECT_UNLOCK (object);
176 gst_valve_get_property (GObject *object,
177 guint prop_id, GValue *value, GParamSpec *pspec)
179 GstValve *valve = GST_VALVE (object);
183 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
186 GST_OBJECT_LOCK (object);
187 g_value_set_boolean (value, valve->drop);
188 GST_OBJECT_UNLOCK (object);
194 gst_valve_transform_ip (GstBaseTransform *trans, GstBuffer *buf)
196 GstValve *valve = GST_VALVE (trans);
197 GstFlowReturn ret = GST_FLOW_OK;
199 GST_OBJECT_LOCK (GST_OBJECT (trans));
201 #if GST_VERSION_MAJOR >= 10 && GST_VERSION_MICRO >= 13
202 ret = GST_BASE_TRANSFORM_FLOW_DROPPED;
206 GST_OBJECT_UNLOCK (GST_OBJECT (trans));
212 gst_valve_event (GstBaseTransform *trans, GstEvent *event)
214 GstValve *valve = GST_VALVE (trans);
217 GST_OBJECT_LOCK (GST_OBJECT (trans));
220 GST_OBJECT_UNLOCK (GST_OBJECT (trans));
226 gst_valve_plugin_init (GstPlugin *plugin)
228 return gst_element_register (plugin, "fsvalve",
229 GST_RANK_MARGINAL, GST_TYPE_VALVE);
232 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
236 gst_valve_plugin_init, VERSION, "LGPL", "Farsight", "http://farsight.sf.net")