gst/mpegstream/: Ref events before sending them to multiple pads, after all gst_pad_s...
[platform/upstream/gstreamer.git] / examples / gob / gst-identity2.gob
1
2 %header{
3 #include <gst/gst.h>
4 #include "gst-identity2.h"
5 #include "gst-identity2-private.h"
6 %}
7
8 class Gst:Identity2 from Gst:Element {
9         
10   /* plugin init */
11   private gboolean
12   plugin_init (GModule *module, GstPlugin *plugin)
13   {
14     static GstElementDetails identity2_details = {
15       "GOB Identity",
16       "Filter/Effect",
17       "Does nothing",
18       "1.0",
19       "Wim Taymans <wim.taymans@chello.be>",
20       "(C) 2001",
21     };
22     GstElementFactory *factory;
23
24     factory = gst_elementfactory_new ("identity2", TYPE_SELF,
25                                       &identity2_details);
26     g_return_val_if_fail (factory != NULL, FALSE);
27
28     gst_plugin_add_feature (plugin, &(factory->feature));
29
30     return TRUE;
31   }
32
33   /* pads FIXME gob oculd be improved here */
34   private GstPad *sinkpad = 
35   {
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);
41   };
42   private GstPad *srcpad =
43   {
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);
47   };
48
49   /* arguments */
50   /*
51   private gboolean loop_based = FALSE; argument BOOL loop_based 
52     get { 
53       ARG = self->_priv->loop_based; 
54     }
55     set { 
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);
60       }
61       else {
62         gst_pad_set_chain_function (self->_priv->sinkpad, chain);
63         gst_element_set_loop_function (GST_ELEMENT (self), NULL);
64       }
65     };*/
66   private guint sleep_time = 0; argument UINT sleep_time link;
67   private gboolean silent = FALSE; argument BOOL silent link;
68
69   /* signals */
70   private signal last NONE(NONE) void handoff(self);
71
72   /* core code here */
73   private GstBufferPool*
74   get_bufferpool (GstPad *pad (check null))
75   {
76     Self *self = SELF (gst_pad_get_parent (pad));
77     
78     return gst_pad_get_bufferpool (self->_priv->srcpad);
79   }
80
81   /* private GstPadNegotiateReturn
82   negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data)
83   {
84     Self *self = SELF (gst_pad_get_parent (pad));
85
86     return gst_pad_negotiate_proxy (pad, self->_priv->sinkpad, caps);
87   }
88
89   private GstPadNegotiateReturn
90   negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
91   {
92     Self *self = SELF (gst_pad_get_parent (pad));
93
94     return gst_pad_negotiate_proxy (pad, self->_priv->srcpad, caps);
95   } */
96
97   private void
98   chain (GstPad *pad (check null), GstBuffer *buf (check null))
99   {
100     Self *self;
101
102     self = SELF (gst_pad_get_parent (pad));
103
104     if (!self->_priv->silent)
105       g_print("identity2: chain ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(pad));
106
107       handoff (self);
108       gst_pad_push (self->_priv->srcpad, buf);
109
110     if (self->_priv->sleep_time)
111       usleep (self->_priv->sleep_time);
112   }
113
114   /*private void
115   loop (GstElement *element (check null))
116   {
117     Self *self = SELF (element);
118     GstBuffer *buf;
119
120     do {
121       buf = gst_pad_pull (self->_priv->sinkpad);
122       g_print("identity2: loop ******* (%s:%s)i \n",GST_DEBUG_PAD_NAME(self->_priv->sinkpad));
123
124       handoff (self);
125       gst_pad_push (self->_priv->srcpad, buf);
126
127       if (self->_priv->sleep_time)
128         usleep (self->_priv->sleep_time);
129
130     } while (!GST_ELEMENT_IS_COTHREAD_STOPPING(element));
131   }*/
132 }
133
134 %{
135 GstPluginDesc plugin_desc = {
136   GST_VERSION_MAJOR,
137   GST_VERSION_MINOR,
138   "identity2",
139   gst_identity2_plugin_init
140 };
141 %}