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