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
313
314
315
316
317
318
319
|
/* vim: set filetype=c: */
% ClassName
GstBaseTransform
% TYPE_CLASS_NAME
GST_TYPE_BASE_TRANSFORM
% pads
srcpad-simple
sinkpad-simple
% pkg-config
gstreamer-base-1.0
% includes
#include <gst/base/gstbasetransform.h>
% prototypes
static GstCaps *gst_replace_transform_caps (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * caps, GstCaps * filter);
static GstCaps *gst_replace_fixate_caps (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
static gboolean gst_replace_accept_caps (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * caps);
static gboolean gst_replace_set_caps (GstBaseTransform * trans,
GstCaps * incaps, GstCaps * outcaps);
static gboolean gst_replace_query (GstBaseTransform * trans,
GstPadDirection direction, GstQuery * query);
static gboolean gst_replace_decide_allocation (GstBaseTransform * trans,
GstQuery * query);
static gboolean gst_replace_filter_meta (GstBaseTransform * trans,
GstQuery * query, GType api, const GstStructure * params);
static gboolean gst_replace_propose_allocation (GstBaseTransform * trans,
GstQuery * decide_query, GstQuery * query);
static gboolean gst_replace_transform_size (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * caps, gsize size, GstCaps * othercaps,
gsize * othersize);
static gboolean gst_replace_get_unit_size (GstBaseTransform * trans,
GstCaps * caps, gsize * size);
static gboolean gst_replace_start (GstBaseTransform * trans);
static gboolean gst_replace_stop (GstBaseTransform * trans);
static gboolean gst_replace_sink_event (GstBaseTransform * trans,
GstEvent * event);
static gboolean gst_replace_src_event (GstBaseTransform * trans,
GstEvent * event);
static GstFlowReturn gst_replace_prepare_output_buffer (GstBaseTransform *
trans, GstBuffer * input, GstBuffer ** outbuf);
static gboolean gst_replace_copy_metadata (GstBaseTransform * trans,
GstBuffer * input, GstBuffer * outbuf);
static gboolean gst_replace_transform_meta (GstBaseTransform * trans,
GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf);
static void gst_replace_before_transform (GstBaseTransform * trans,
GstBuffer * buffer);
static GstFlowReturn gst_replace_transform (GstBaseTransform * trans,
GstBuffer * inbuf, GstBuffer * outbuf);
static GstFlowReturn gst_replace_transform_ip (GstBaseTransform * trans,
GstBuffer * buf);
% declare-class
GstBaseTransformClass *base_transform_class = GST_BASE_TRANSFORM_CLASS (klass);
% set-methods
base_transform_class->transform_caps = GST_DEBUG_FUNCPTR (gst_replace_transform_caps);
base_transform_class->fixate_caps = GST_DEBUG_FUNCPTR (gst_replace_fixate_caps);
base_transform_class->accept_caps = GST_DEBUG_FUNCPTR (gst_replace_accept_caps);
base_transform_class->set_caps = GST_DEBUG_FUNCPTR (gst_replace_set_caps);
base_transform_class->query = GST_DEBUG_FUNCPTR (gst_replace_query);
base_transform_class->decide_allocation = GST_DEBUG_FUNCPTR (gst_replace_decide_allocation);
base_transform_class->filter_meta = GST_DEBUG_FUNCPTR (gst_replace_filter_meta);
base_transform_class->propose_allocation = GST_DEBUG_FUNCPTR (gst_replace_propose_allocation);
base_transform_class->transform_size = GST_DEBUG_FUNCPTR (gst_replace_transform_size);
base_transform_class->get_unit_size = GST_DEBUG_FUNCPTR (gst_replace_get_unit_size);
base_transform_class->start = GST_DEBUG_FUNCPTR (gst_replace_start);
base_transform_class->stop = GST_DEBUG_FUNCPTR (gst_replace_stop);
base_transform_class->sink_event = GST_DEBUG_FUNCPTR (gst_replace_sink_event);
base_transform_class->src_event = GST_DEBUG_FUNCPTR (gst_replace_src_event);
base_transform_class->prepare_output_buffer = GST_DEBUG_FUNCPTR (gst_replace_prepare_output_buffer);
base_transform_class->copy_metadata = GST_DEBUG_FUNCPTR (gst_replace_copy_metadata);
base_transform_class->transform_meta = GST_DEBUG_FUNCPTR (gst_replace_transform_meta);
base_transform_class->before_transform = GST_DEBUG_FUNCPTR (gst_replace_before_transform);
base_transform_class->transform = GST_DEBUG_FUNCPTR (gst_replace_transform);
base_transform_class->transform_ip = GST_DEBUG_FUNCPTR (gst_replace_transform_ip);
% methods
static GstCaps *
gst_replace_transform_caps (GstBaseTransform * trans, GstPadDirection direction,
GstCaps * caps, GstCaps * filter)
{
GstReplace *replace = GST_REPLACE (trans);
GstCaps *othercaps;
GST_DEBUG_OBJECT (replace, "transform_caps");
othercaps = gst_caps_copy (caps);
/* Copy other caps and modify as appropriate */
/* This works for the simplest cases, where the transform modifies one
* or more fields in the caps structure. It does not work correctly
* if passthrough caps are preferred. */
if (direction == GST_PAD_SRC) {
/* transform caps going upstream */
} else {
/* transform caps going downstream */
}
if (filter) {
GstCaps *intersect;
intersect = gst_caps_intersect (othercaps, filter);
gst_caps_unref (othercaps);
return intersect;
} else {
return othercaps;
}
}
static GstCaps *
gst_replace_fixate_caps (GstBaseTransform * trans, GstPadDirection direction,
GstCaps * caps, GstCaps * othercaps)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "fixate_caps");
return NULL;
}
static gboolean
gst_replace_accept_caps (GstBaseTransform * trans, GstPadDirection direction,
GstCaps * caps)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "accept_caps");
return TRUE;
}
static gboolean
gst_replace_set_caps (GstBaseTransform * trans, GstCaps * incaps,
GstCaps * outcaps)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "set_caps");
return TRUE;
}
static gboolean
gst_replace_query (GstBaseTransform * trans, GstPadDirection direction,
GstQuery * query)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "query");
return TRUE;
}
/* decide allocation query for output buffers */
static gboolean
gst_replace_decide_allocation (GstBaseTransform * trans, GstQuery * query)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "decide_allocation");
return TRUE;
}
static gboolean
gst_replace_filter_meta (GstBaseTransform * trans, GstQuery * query, GType api,
const GstStructure * params)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "filter_meta");
return TRUE;
}
/* propose allocation query parameters for input buffers */
static gboolean
gst_replace_propose_allocation (GstBaseTransform * trans,
GstQuery * decide_query, GstQuery * query)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "propose_allocation");
return TRUE;
}
/* transform size */
static gboolean
gst_replace_transform_size (GstBaseTransform * trans, GstPadDirection direction,
GstCaps * caps, gsize size, GstCaps * othercaps, gsize * othersize)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "transform_size");
return TRUE;
}
static gboolean
gst_replace_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
gsize * size)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "get_unit_size");
return TRUE;
}
/* states */
static gboolean
gst_replace_start (GstBaseTransform * trans)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "start");
return TRUE;
}
static gboolean
gst_replace_stop (GstBaseTransform * trans)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "stop");
return TRUE;
}
/* sink and src pad event handlers */
static gboolean
gst_replace_sink_event (GstBaseTransform * trans, GstEvent * event)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "sink_event");
return GST_BASE_TRANSFORM_CLASS (gst_replace_parent_class)->sink_event (
trans, event);
}
static gboolean
gst_replace_src_event (GstBaseTransform * trans, GstEvent * event)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "src_event");
return GST_BASE_TRANSFORM_CLASS (gst_replace_parent_class)->src_event (
trans, event);
}
static GstFlowReturn
gst_replace_prepare_output_buffer (GstBaseTransform * trans, GstBuffer * input,
GstBuffer ** outbuf)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "prepare_output_buffer");
return GST_FLOW_OK;
}
/* metadata */
static gboolean
gst_replace_copy_metadata (GstBaseTransform * trans, GstBuffer * input,
GstBuffer * outbuf)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "copy_metadata");
return TRUE;
}
static gboolean
gst_replace_transform_meta (GstBaseTransform * trans, GstBuffer * outbuf,
GstMeta * meta, GstBuffer * inbuf)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "transform_meta");
return TRUE;
}
static void
gst_replace_before_transform (GstBaseTransform * trans, GstBuffer * buffer)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "before_transform");
}
/* transform */
static GstFlowReturn
gst_replace_transform (GstBaseTransform * trans, GstBuffer * inbuf,
GstBuffer * outbuf)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "transform");
return GST_FLOW_OK;
}
static GstFlowReturn
gst_replace_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
{
GstReplace *replace = GST_REPLACE (trans);
GST_DEBUG_OBJECT (replace, "transform_ip");
return GST_FLOW_OK;
}
% end
|