element-maker: improve generation of several classes
[platform/upstream/gstreamer.git] / tools / sinkpad.c
1
2 % instance-members
3   GstPad *sinkpad;
4 % prototypes
5
6 static GstCaps* gst_replace_sink_getcaps (GstPad *pad);
7 static gboolean gst_replace_sink_setcaps (GstPad *pad, GstCaps *caps);
8 static gboolean gst_replace_sink_acceptcaps (GstPad *pad, GstCaps *caps);
9 static void gst_replace_sink_fixatecaps (GstPad *pad, GstCaps *caps);
10 static gboolean gst_replace_sink_activate (GstPad *pad);
11 static gboolean gst_replace_sink_activatepush (GstPad *pad, gboolean active);
12 static gboolean gst_replace_sink_activatepull (GstPad *pad, gboolean active);
13 static GstPadLinkReturn gst_replace_sink_link (GstPad *pad, GstPad *peer);
14 static void gst_replace_sink_unlink (GstPad *pad);
15 static GstFlowReturn gst_replace_sink_chain (GstPad *pad, GstBuffer *buffer);
16 static GstFlowReturn gst_replace_sink_chainlist (GstPad *pad, GstBufferList *bufferlist);
17 static gboolean gst_replace_sink_event (GstPad *pad, GstEvent *event);
18 static gboolean gst_replace_sink_query (GstPad *pad, GstQuery *query);
19 static GstFlowReturn gst_replace_sink_bufferalloc (GstPad *pad, guint64 offset, guint size,
20     GstCaps *caps, GstBuffer **buf);
21 static GstIterator * gst_replace_sink_iterintlink (GstPad *pad);
22
23 % pad-template
24 static GstStaticPadTemplate gst_replace_sink_template =
25 GST_STATIC_PAD_TEMPLATE ("sink",
26     GST_PAD_SINK,
27     GST_PAD_ALWAYS,
28     GST_STATIC_CAPS ("application/unknown")
29     );
30
31 % base-init
32   gst_element_class_add_pad_template (element_class,
33       gst_static_pad_template_get (&gst_replace_sink_template));
34 % instance-init
35
36   replace->sinkpad = gst_pad_new_from_static_template (&gst_replace_sink_template
37       ,     
38             "sink");
39   gst_pad_set_getcaps_function (replace->sinkpad,
40             GST_DEBUG_FUNCPTR(gst_replace_sink_getcaps));
41   gst_pad_set_setcaps_function (replace->sinkpad,
42             GST_DEBUG_FUNCPTR(gst_replace_sink_setcaps));
43   gst_pad_set_acceptcaps_function (replace->sinkpad,
44             GST_DEBUG_FUNCPTR(gst_replace_sink_acceptcaps));
45   gst_pad_set_fixatecaps_function (replace->sinkpad,
46             GST_DEBUG_FUNCPTR(gst_replace_sink_fixatecaps));
47   gst_pad_set_activate_function (replace->sinkpad,
48             GST_DEBUG_FUNCPTR(gst_replace_sink_activate));
49   gst_pad_set_activatepush_function (replace->sinkpad,
50             GST_DEBUG_FUNCPTR(gst_replace_sink_activatepush));
51   gst_pad_set_activatepull_function (replace->sinkpad,
52             GST_DEBUG_FUNCPTR(gst_replace_sink_activatepull));
53   gst_pad_set_link_function (replace->sinkpad,
54             GST_DEBUG_FUNCPTR(gst_replace_sink_link));
55   gst_pad_set_unlink_function (replace->sinkpad,
56             GST_DEBUG_FUNCPTR(gst_replace_sink_unlink));
57   gst_pad_set_chain_function (replace->sinkpad,
58             GST_DEBUG_FUNCPTR(gst_replace_sink_chain));
59   gst_pad_set_chain_list_function (replace->sinkpad,
60             GST_DEBUG_FUNCPTR(gst_replace_sink_chainlist));
61   gst_pad_set_event_function (replace->sinkpad,
62             GST_DEBUG_FUNCPTR(gst_replace_sink_event));
63   gst_pad_set_query_function (replace->sinkpad,
64             GST_DEBUG_FUNCPTR(gst_replace_sink_query));
65   gst_pad_set_bufferalloc_function (replace->sinkpad,
66             GST_DEBUG_FUNCPTR(gst_replace_sink_bufferalloc));
67   gst_pad_set_iterate_internal_links_function (replace->sinkpad,
68             GST_DEBUG_FUNCPTR(gst_replace_sink_iterintlink));
69   gst_element_add_pad (GST_ELEMENT(replace), replace->sinkpad);
70
71
72 % methods
73
74 static GstCaps*
75 gst_replace_sink_getcaps (GstPad *pad)
76 {
77   GstReplace *replace;
78   GstCaps *caps;
79
80   replace = GST_REPLACE (gst_pad_get_parent (pad));
81
82   GST_DEBUG_OBJECT(replace, "getcaps");
83
84   caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
85
86   gst_object_unref (replace);
87   return caps;
88 }
89
90 static gboolean
91 gst_replace_sink_setcaps (GstPad *pad, GstCaps *caps)
92 {
93   GstReplace *replace;
94
95   replace = GST_REPLACE (gst_pad_get_parent (pad));
96
97   GST_DEBUG_OBJECT(replace, "setcaps");
98
99
100   gst_object_unref (replace);
101   return TRUE;
102 }
103
104 static gboolean
105 gst_replace_sink_acceptcaps (GstPad *pad, GstCaps *caps)
106 {
107   GstReplace *replace;
108
109   replace = GST_REPLACE (gst_pad_get_parent (pad));
110
111   GST_DEBUG_OBJECT(replace, "acceptcaps");
112
113
114   gst_object_unref (replace);
115   return TRUE;
116 }
117
118 static void
119 gst_replace_sink_fixatecaps (GstPad *pad, GstCaps *caps)
120 {
121   GstReplace *replace;
122
123   replace = GST_REPLACE (gst_pad_get_parent (pad));
124
125   GST_DEBUG_OBJECT(replace, "fixatecaps");
126
127
128   gst_object_unref (replace);
129 }
130
131 static gboolean
132 gst_replace_sink_activate (GstPad *pad)
133 {
134   GstReplace *replace;
135   gboolean ret;
136
137   replace = GST_REPLACE (gst_pad_get_parent (pad));
138
139   GST_DEBUG_OBJECT(replace, "activate");
140
141   if (gst_pad_check_pull_range (pad)) {
142     GST_DEBUG_OBJECT (pad, "activating pull");
143     ret = gst_pad_activate_pull (pad, TRUE);
144   } else {
145     GST_DEBUG_OBJECT (pad, "activating push");
146     ret = gst_pad_activate_push (pad, TRUE);
147   }
148
149   gst_object_unref (replace);
150   return ret;
151 }
152
153 static gboolean
154 gst_replace_sink_activatepush (GstPad *pad, gboolean active)
155 {
156   GstReplace *replace;
157
158   replace = GST_REPLACE (gst_pad_get_parent (pad));
159
160   GST_DEBUG_OBJECT(replace, "activatepush");
161
162
163   gst_object_unref (replace);
164   return TRUE;
165 }
166
167 static gboolean
168 gst_replace_sink_activatepull (GstPad *pad, gboolean active)
169 {
170   GstReplace *replace;
171
172   replace = GST_REPLACE (gst_pad_get_parent (pad));
173
174   GST_DEBUG_OBJECT(replace, "activatepull");
175
176
177   gst_object_unref (replace);
178   return TRUE;
179 }
180
181 static GstPadLinkReturn
182 gst_replace_sink_link (GstPad *pad, GstPad *peer)
183 {
184   GstReplace *replace;
185
186   replace = GST_REPLACE (gst_pad_get_parent (pad));
187
188   GST_DEBUG_OBJECT(replace, "link");
189
190
191   gst_object_unref (replace);
192   return GST_PAD_LINK_OK;
193 }
194
195 static void
196 gst_replace_sink_unlink (GstPad *pad)
197 {
198   GstReplace *replace;
199
200   replace = GST_REPLACE (gst_pad_get_parent (pad));
201
202   GST_DEBUG_OBJECT(replace, "unlink");
203
204
205   gst_object_unref (replace);
206 }
207
208 static GstFlowReturn
209 gst_replace_sink_chain (GstPad *pad, GstBuffer *buffer)
210 {
211   GstReplace *replace;
212
213   replace = GST_REPLACE (gst_pad_get_parent (pad));
214
215   GST_DEBUG_OBJECT(replace, "chain");
216
217
218   gst_object_unref (replace);
219   return GST_FLOW_OK;
220 }
221
222 static GstFlowReturn
223 gst_replace_sink_chainlist (GstPad *pad, GstBufferList *bufferlist)
224 {
225   GstReplace *replace;
226
227   replace = GST_REPLACE (gst_pad_get_parent (pad));
228
229   GST_DEBUG_OBJECT(replace, "chainlist");
230
231
232   gst_object_unref (replace);
233   return GST_FLOW_OK;
234 }
235
236 static gboolean
237 gst_replace_sink_event (GstPad *pad, GstEvent *event)
238 {
239   gboolean res;
240   GstReplace *replace;
241
242   replace = GST_REPLACE (gst_pad_get_parent (pad));
243
244   GST_DEBUG_OBJECT(replace, "event");
245
246   switch (GST_EVENT_TYPE (event)) {
247     default:
248       res = gst_pad_event_default (pad, event);
249       break;
250   }
251
252   gst_object_unref (replace);
253   return res;
254 }
255
256 static gboolean
257 gst_replace_sink_query (GstPad *pad, GstQuery *query)
258 {
259   gboolean res;
260   GstReplace *replace;
261
262   replace = GST_REPLACE (gst_pad_get_parent (pad));
263
264   GST_DEBUG_OBJECT(replace, "query");
265
266   switch (GST_QUERY_TYPE(query)) {
267     default:
268       res = gst_pad_query_default (pad, query);
269       break;
270   }
271
272   gst_object_unref (replace);
273   return res;
274 }
275
276 static GstFlowReturn
277 gst_replace_sink_bufferalloc (GstPad *pad, guint64 offset, guint size,
278     GstCaps *caps, GstBuffer **buf)
279 {
280   GstReplace *replace;
281
282   replace = GST_REPLACE (gst_pad_get_parent (pad));
283
284   GST_DEBUG_OBJECT(replace, "bufferalloc");
285
286
287   *buf = gst_buffer_new_and_alloc (size);
288   gst_buffer_set_caps (*buf, caps);
289
290   gst_object_unref (replace);
291   return GST_FLOW_OK;
292 }
293
294 static GstIterator *
295 gst_replace_sink_iterintlink (GstPad *pad)
296 {
297   GstReplace *replace;
298   GstIterator *iter;
299
300   replace = GST_REPLACE (gst_pad_get_parent (pad));
301
302   GST_DEBUG_OBJECT(replace, "iterintlink");
303
304   iter = gst_pad_iterate_internal_links_default (pad);
305
306   gst_object_unref (replace);
307   return iter;
308 }
309
310 % end
311