4 #include "gst-identity2.h"
5 #include "gst-identity2-private.h"
8 class Gst:Identity2 from Gst:Element {
12 plugin_init (GModule *module, GstPlugin *plugin)
14 static GstElementDetails identity2_details = {
19 "Wim Taymans <wim.taymans@chello.be>",
22 GstElementFactory *factory;
24 factory = gst_elementfactory_new ("identity2", TYPE_SELF,
26 g_return_val_if_fail (factory != NULL, FALSE);
28 gst_plugin_add_feature (plugin, &(factory->feature));
33 /* pads FIXME gob oculd be improved here */
34 private GstPad *sinkpad =
36 gst_pad_new ("sink", GST_PAD_SINK);
37 gst_element_add_pad (GST_ELEMENT (o), o->_priv->sinkpad);
38 gst_pad_set_chain_function (o->_priv->sinkpad, chain);
39 gst_pad_set_bufferpool_function (o->_priv->sinkpad, get_bufferpool);
40 //gst_pad_set_negotiate_function (o->_priv->sinkpad, negotiate_sink);
42 private GstPad *srcpad =
44 gst_pad_new ("src", GST_PAD_SRC);
45 gst_element_add_pad (GST_ELEMENT (o), o->_priv->srcpad);
46 //gst_pad_set_negotiate_function (o->_priv->srcpad, negotiate_src);
51 private gboolean loop_based = FALSE; argument BOOL loop_based
53 ARG = self->_priv->loop_based;
56 self->_priv->loop_based = ARG;
57 if (self->_priv->loop_based) {
58 gst_element_set_loop_function (GST_ELEMENT (self), loop);
59 gst_pad_set_chain_function (self->_priv->sinkpad, NULL);
62 gst_pad_set_chain_function (self->_priv->sinkpad, chain);
63 gst_element_set_loop_function (GST_ELEMENT (self), NULL);
66 private guint sleep_time = 0; argument UINT sleep_time link;
67 private gboolean silent = FALSE; argument BOOL silent link;
70 private signal last NONE(NONE) void handoff(self);
73 private GstBufferPool*
74 get_bufferpool (GstPad *pad (check null))
76 Self *self = SELF (gst_pad_get_parent (pad));
78 return gst_pad_get_bufferpool (self->_priv->srcpad);
81 /* private GstPadNegotiateReturn
82 negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data)
84 Self *self = SELF (gst_pad_get_parent (pad));
86 return gst_pad_negotiate_proxy (pad, self->_priv->sinkpad, caps);
89 private GstPadNegotiateReturn
90 negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
92 Self *self = SELF (gst_pad_get_parent (pad));
94 return gst_pad_negotiate_proxy (pad, self->_priv->srcpad, caps);
98 chain (GstPad *pad (check null), GstBuffer *buf (check null))
102 self = SELF (gst_pad_get_parent (pad));
104 if (!self->_priv->silent)
105 g_print("identity2: chain ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(pad));
108 gst_pad_push (self->_priv->srcpad, buf);
110 if (self->_priv->sleep_time)
111 usleep (self->_priv->sleep_time);
115 loop (GstElement *element (check null))
117 Self *self = SELF (element);
121 buf = gst_pad_pull (self->_priv->sinkpad);
122 g_print("identity2: loop ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(self->_priv->sinkpad));
125 gst_pad_push (self->_priv->srcpad, buf);
127 if (self->_priv->sleep_time)
128 usleep (self->_priv->sleep_time);
130 } while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
135 GstPluginDesc plugin_desc = {
139 gst_identity2_plugin_init