summaryrefslogtreecommitdiff
path: root/tools/element-templates/basesrc
blob: 2dcf66bc1ab0b8cc8dbdd0f53226f3dc2c9092fb (plain)
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
/* vim: set filetype=c: */
% ClassName
GstBaseSrc
% TYPE_CLASS_NAME
GST_TYPE_BASE_SRC
% pads
srcpad-simple
% pkg-config
gstreamer-base-1.0
% includes
#include <gst/base/gstbasesrc.h>
% prototypes
static GstCaps *gst_replace_get_caps (GstBaseSrc * src, GstCaps * filter);
static gboolean gst_replace_negotiate (GstBaseSrc * src);
static GstCaps *gst_replace_fixate (GstBaseSrc * src, GstCaps * caps);
static gboolean gst_replace_set_caps (GstBaseSrc * src, GstCaps * caps);
static gboolean gst_replace_decide_allocation (GstBaseSrc * src,
    GstQuery * query);
static gboolean gst_replace_start (GstBaseSrc * src);
static gboolean gst_replace_stop (GstBaseSrc * src);
static void gst_replace_get_times (GstBaseSrc * src, GstBuffer * buffer,
    GstClockTime * start, GstClockTime * end);
static gboolean gst_replace_get_size (GstBaseSrc * src, guint64 * size);
static gboolean gst_replace_is_seekable (GstBaseSrc * src);
static gboolean gst_replace_prepare_seek_segment (GstBaseSrc * src,
    GstEvent * seek, GstSegment * segment);
static gboolean gst_replace_do_seek (GstBaseSrc * src, GstSegment * segment);
static gboolean gst_replace_unlock (GstBaseSrc * src);
static gboolean gst_replace_unlock_stop (GstBaseSrc * src);
static gboolean gst_replace_query (GstBaseSrc * src, GstQuery * query);
static gboolean gst_replace_event (GstBaseSrc * src, GstEvent * event);
static GstFlowReturn gst_replace_create (GstBaseSrc * src, guint64 offset,
    guint size, GstBuffer ** buf);
static GstFlowReturn gst_replace_alloc (GstBaseSrc * src, guint64 offset,
    guint size, GstBuffer ** buf);
static GstFlowReturn gst_replace_fill (GstBaseSrc * src, guint64 offset,
    guint size, GstBuffer * buf);
% declare-class
  GstBaseSrcClass *base_src_class = GST_BASE_SRC_CLASS (klass);
% set-methods
  base_src_class->get_caps = GST_DEBUG_FUNCPTR (gst_replace_get_caps);
  base_src_class->negotiate = GST_DEBUG_FUNCPTR (gst_replace_negotiate);
  base_src_class->fixate = GST_DEBUG_FUNCPTR (gst_replace_fixate);
  base_src_class->set_caps = GST_DEBUG_FUNCPTR (gst_replace_set_caps);
  base_src_class->decide_allocation = GST_DEBUG_FUNCPTR (gst_replace_decide_allocation);
  base_src_class->start = GST_DEBUG_FUNCPTR (gst_replace_start);
  base_src_class->stop = GST_DEBUG_FUNCPTR (gst_replace_stop);
  base_src_class->get_times = GST_DEBUG_FUNCPTR (gst_replace_get_times);
  base_src_class->get_size = GST_DEBUG_FUNCPTR (gst_replace_get_size);
  base_src_class->is_seekable = GST_DEBUG_FUNCPTR (gst_replace_is_seekable);
  base_src_class->prepare_seek_segment = GST_DEBUG_FUNCPTR (gst_replace_prepare_seek_segment);
  base_src_class->do_seek = GST_DEBUG_FUNCPTR (gst_replace_do_seek);
  base_src_class->unlock = GST_DEBUG_FUNCPTR (gst_replace_unlock);
  base_src_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_replace_unlock_stop);
  base_src_class->query = GST_DEBUG_FUNCPTR (gst_replace_query);
  base_src_class->event = GST_DEBUG_FUNCPTR (gst_replace_event);
  base_src_class->create = GST_DEBUG_FUNCPTR (gst_replace_create);
  base_src_class->alloc = GST_DEBUG_FUNCPTR (gst_replace_alloc);
  base_src_class->fill = GST_DEBUG_FUNCPTR (gst_replace_fill);
% methods
/* get caps from subclass */
static GstCaps *
gst_replace_get_caps (GstBaseSrc * src, GstCaps * filter)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "get_caps");

  return NULL;
}

/* decide on caps */
static gboolean
gst_replace_negotiate (GstBaseSrc * src)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "negotiate");

  return TRUE;
}

/* called if, in negotiation, caps need fixating */
static GstCaps *
gst_replace_fixate (GstBaseSrc * src, GstCaps * caps)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "fixate");

  return NULL;
}

/* notify the subclass of new caps */
static gboolean
gst_replace_set_caps (GstBaseSrc * src, GstCaps * caps)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "set_caps");

  return TRUE;
}

/* setup allocation query */
static gboolean
gst_replace_decide_allocation (GstBaseSrc * src, GstQuery * query)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "decide_allocation");

  return TRUE;
}

/* start and stop processing, ideal for opening/closing the resource */
static gboolean
gst_replace_start (GstBaseSrc * src)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "start");

  return TRUE;
}

static gboolean
gst_replace_stop (GstBaseSrc * src)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "stop");

  return TRUE;
}

/* given a buffer, return start and stop time when it should be pushed
 * out. The base class will sync on the clock using these times. */
static void
gst_replace_get_times (GstBaseSrc * src, GstBuffer * buffer,
    GstClockTime * start, GstClockTime * end)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "get_times");

}

/* get the total size of the resource in bytes */
static gboolean
gst_replace_get_size (GstBaseSrc * src, guint64 * size)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "get_size");

  return TRUE;
}

/* check if the resource is seekable */
static gboolean
gst_replace_is_seekable (GstBaseSrc * src)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "is_seekable");

  return TRUE;
}

/* Prepare the segment on which to perform do_seek(), converting to the
 * current basesrc format. */
static gboolean
gst_replace_prepare_seek_segment (GstBaseSrc * src, GstEvent * seek,
    GstSegment * segment)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "prepare_seek_segment");

  return TRUE;
}

/* notify subclasses of a seek */
static gboolean
gst_replace_do_seek (GstBaseSrc * src, GstSegment * segment)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "do_seek");

  return TRUE;
}

/* unlock any pending access to the resource. subclasses should unlock
 * any function ASAP. */
static gboolean
gst_replace_unlock (GstBaseSrc * src)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "unlock");

  return TRUE;
}

/* Clear any pending unlock request, as we succeeded in unlocking */
static gboolean
gst_replace_unlock_stop (GstBaseSrc * src)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "unlock_stop");

  return TRUE;
}

/* notify subclasses of a query */
static gboolean
gst_replace_query (GstBaseSrc * src, GstQuery * query)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "query");

  return TRUE;
}

/* notify subclasses of an event */
static gboolean
gst_replace_event (GstBaseSrc * src, GstEvent * event)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "event");

  return TRUE;
}

/* ask the subclass to create a buffer with offset and size, the default
 * implementation will call alloc and fill. */
static GstFlowReturn
gst_replace_create (GstBaseSrc * src, guint64 offset, guint size,
    GstBuffer ** buf)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "create");

  return GST_FLOW_OK;
}

/* ask the subclass to allocate an output buffer. The default implementation
 * will use the negotiated allocator. */
static GstFlowReturn
gst_replace_alloc (GstBaseSrc * src, guint64 offset, guint size,
    GstBuffer ** buf)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "alloc");

  return GST_FLOW_OK;
}

/* ask the subclass to fill the buffer with data from offset and size */
static GstFlowReturn
gst_replace_fill (GstBaseSrc * src, guint64 offset, guint size, GstBuffer * buf)
{
  GstReplace *replace = GST_REPLACE (src);

  GST_DEBUG_OBJECT (replace, "fill");

  return GST_FLOW_OK;
}
% end