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