• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* vim: set filetype=c: */
2% ClassName
3GstBaseSrc
4% TYPE_CLASS_NAME
5GST_TYPE_BASE_SRC
6% pads
7srcpad-simple
8% pkg-config
9gstreamer-base-1.0
10% includes
11#include <gst/base/gstbasesrc.h>
12% prototypes
13static GstCaps *gst_replace_get_caps (GstBaseSrc * src, GstCaps * filter);
14static gboolean gst_replace_negotiate (GstBaseSrc * src);
15static GstCaps *gst_replace_fixate (GstBaseSrc * src, GstCaps * caps);
16static gboolean gst_replace_set_caps (GstBaseSrc * src, GstCaps * caps);
17static gboolean gst_replace_decide_allocation (GstBaseSrc * src,
18    GstQuery * query);
19static gboolean gst_replace_start (GstBaseSrc * src);
20static gboolean gst_replace_stop (GstBaseSrc * src);
21static void gst_replace_get_times (GstBaseSrc * src, GstBuffer * buffer,
22    GstClockTime * start, GstClockTime * end);
23static gboolean gst_replace_get_size (GstBaseSrc * src, guint64 * size);
24static gboolean gst_replace_is_seekable (GstBaseSrc * src);
25static gboolean gst_replace_prepare_seek_segment (GstBaseSrc * src,
26    GstEvent * seek, GstSegment * segment);
27static gboolean gst_replace_do_seek (GstBaseSrc * src, GstSegment * segment);
28static gboolean gst_replace_unlock (GstBaseSrc * src);
29static gboolean gst_replace_unlock_stop (GstBaseSrc * src);
30static gboolean gst_replace_query (GstBaseSrc * src, GstQuery * query);
31static gboolean gst_replace_event (GstBaseSrc * src, GstEvent * event);
32static GstFlowReturn gst_replace_create (GstBaseSrc * src, guint64 offset,
33    guint size, GstBuffer ** buf);
34static GstFlowReturn gst_replace_alloc (GstBaseSrc * src, guint64 offset,
35    guint size, GstBuffer ** buf);
36static GstFlowReturn gst_replace_fill (GstBaseSrc * src, guint64 offset,
37    guint size, GstBuffer * buf);
38% declare-class
39  GstBaseSrcClass *base_src_class = GST_BASE_SRC_CLASS (klass);
40% set-methods
41  base_src_class->get_caps = GST_DEBUG_FUNCPTR (gst_replace_get_caps);
42  base_src_class->negotiate = GST_DEBUG_FUNCPTR (gst_replace_negotiate);
43  base_src_class->fixate = GST_DEBUG_FUNCPTR (gst_replace_fixate);
44  base_src_class->set_caps = GST_DEBUG_FUNCPTR (gst_replace_set_caps);
45  base_src_class->decide_allocation = GST_DEBUG_FUNCPTR (gst_replace_decide_allocation);
46  base_src_class->start = GST_DEBUG_FUNCPTR (gst_replace_start);
47  base_src_class->stop = GST_DEBUG_FUNCPTR (gst_replace_stop);
48  base_src_class->get_times = GST_DEBUG_FUNCPTR (gst_replace_get_times);
49  base_src_class->get_size = GST_DEBUG_FUNCPTR (gst_replace_get_size);
50  base_src_class->is_seekable = GST_DEBUG_FUNCPTR (gst_replace_is_seekable);
51  base_src_class->prepare_seek_segment = GST_DEBUG_FUNCPTR (gst_replace_prepare_seek_segment);
52  base_src_class->do_seek = GST_DEBUG_FUNCPTR (gst_replace_do_seek);
53  base_src_class->unlock = GST_DEBUG_FUNCPTR (gst_replace_unlock);
54  base_src_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_replace_unlock_stop);
55  base_src_class->query = GST_DEBUG_FUNCPTR (gst_replace_query);
56  base_src_class->event = GST_DEBUG_FUNCPTR (gst_replace_event);
57  base_src_class->create = GST_DEBUG_FUNCPTR (gst_replace_create);
58  base_src_class->alloc = GST_DEBUG_FUNCPTR (gst_replace_alloc);
59  base_src_class->fill = GST_DEBUG_FUNCPTR (gst_replace_fill);
60% methods
61/* get caps from subclass */
62static GstCaps *
63gst_replace_get_caps (GstBaseSrc * src, GstCaps * filter)
64{
65  GstReplace *replace = GST_REPLACE (src);
66
67  GST_DEBUG_OBJECT (replace, "get_caps");
68
69  return NULL;
70}
71
72/* decide on caps */
73static gboolean
74gst_replace_negotiate (GstBaseSrc * src)
75{
76  GstReplace *replace = GST_REPLACE (src);
77
78  GST_DEBUG_OBJECT (replace, "negotiate");
79
80  return TRUE;
81}
82
83/* called if, in negotiation, caps need fixating */
84static GstCaps *
85gst_replace_fixate (GstBaseSrc * src, GstCaps * caps)
86{
87  GstReplace *replace = GST_REPLACE (src);
88
89  GST_DEBUG_OBJECT (replace, "fixate");
90
91  return NULL;
92}
93
94/* notify the subclass of new caps */
95static gboolean
96gst_replace_set_caps (GstBaseSrc * src, GstCaps * caps)
97{
98  GstReplace *replace = GST_REPLACE (src);
99
100  GST_DEBUG_OBJECT (replace, "set_caps");
101
102  return TRUE;
103}
104
105/* setup allocation query */
106static gboolean
107gst_replace_decide_allocation (GstBaseSrc * src, GstQuery * query)
108{
109  GstReplace *replace = GST_REPLACE (src);
110
111  GST_DEBUG_OBJECT (replace, "decide_allocation");
112
113  return TRUE;
114}
115
116/* start and stop processing, ideal for opening/closing the resource */
117static gboolean
118gst_replace_start (GstBaseSrc * src)
119{
120  GstReplace *replace = GST_REPLACE (src);
121
122  GST_DEBUG_OBJECT (replace, "start");
123
124  return TRUE;
125}
126
127static gboolean
128gst_replace_stop (GstBaseSrc * src)
129{
130  GstReplace *replace = GST_REPLACE (src);
131
132  GST_DEBUG_OBJECT (replace, "stop");
133
134  return TRUE;
135}
136
137/* given a buffer, return start and stop time when it should be pushed
138 * out. The base class will sync on the clock using these times. */
139static void
140gst_replace_get_times (GstBaseSrc * src, GstBuffer * buffer,
141    GstClockTime * start, GstClockTime * end)
142{
143  GstReplace *replace = GST_REPLACE (src);
144
145  GST_DEBUG_OBJECT (replace, "get_times");
146
147}
148
149/* get the total size of the resource in bytes */
150static gboolean
151gst_replace_get_size (GstBaseSrc * src, guint64 * size)
152{
153  GstReplace *replace = GST_REPLACE (src);
154
155  GST_DEBUG_OBJECT (replace, "get_size");
156
157  return TRUE;
158}
159
160/* check if the resource is seekable */
161static gboolean
162gst_replace_is_seekable (GstBaseSrc * src)
163{
164  GstReplace *replace = GST_REPLACE (src);
165
166  GST_DEBUG_OBJECT (replace, "is_seekable");
167
168  return TRUE;
169}
170
171/* Prepare the segment on which to perform do_seek(), converting to the
172 * current basesrc format. */
173static gboolean
174gst_replace_prepare_seek_segment (GstBaseSrc * src, GstEvent * seek,
175    GstSegment * segment)
176{
177  GstReplace *replace = GST_REPLACE (src);
178
179  GST_DEBUG_OBJECT (replace, "prepare_seek_segment");
180
181  return TRUE;
182}
183
184/* notify subclasses of a seek */
185static gboolean
186gst_replace_do_seek (GstBaseSrc * src, GstSegment * segment)
187{
188  GstReplace *replace = GST_REPLACE (src);
189
190  GST_DEBUG_OBJECT (replace, "do_seek");
191
192  return TRUE;
193}
194
195/* unlock any pending access to the resource. subclasses should unlock
196 * any function ASAP. */
197static gboolean
198gst_replace_unlock (GstBaseSrc * src)
199{
200  GstReplace *replace = GST_REPLACE (src);
201
202  GST_DEBUG_OBJECT (replace, "unlock");
203
204  return TRUE;
205}
206
207/* Clear any pending unlock request, as we succeeded in unlocking */
208static gboolean
209gst_replace_unlock_stop (GstBaseSrc * src)
210{
211  GstReplace *replace = GST_REPLACE (src);
212
213  GST_DEBUG_OBJECT (replace, "unlock_stop");
214
215  return TRUE;
216}
217
218/* notify subclasses of a query */
219static gboolean
220gst_replace_query (GstBaseSrc * src, GstQuery * query)
221{
222  GstReplace *replace = GST_REPLACE (src);
223
224  GST_DEBUG_OBJECT (replace, "query");
225
226  return TRUE;
227}
228
229/* notify subclasses of an event */
230static gboolean
231gst_replace_event (GstBaseSrc * src, GstEvent * event)
232{
233  GstReplace *replace = GST_REPLACE (src);
234
235  GST_DEBUG_OBJECT (replace, "event");
236
237  return TRUE;
238}
239
240/* ask the subclass to create a buffer with offset and size, the default
241 * implementation will call alloc and fill. */
242static GstFlowReturn
243gst_replace_create (GstBaseSrc * src, guint64 offset, guint size,
244    GstBuffer ** buf)
245{
246  GstReplace *replace = GST_REPLACE (src);
247
248  GST_DEBUG_OBJECT (replace, "create");
249
250  return GST_FLOW_OK;
251}
252
253/* ask the subclass to allocate an output buffer. The default implementation
254 * will use the negotiated allocator. */
255static GstFlowReturn
256gst_replace_alloc (GstBaseSrc * src, guint64 offset, guint size,
257    GstBuffer ** buf)
258{
259  GstReplace *replace = GST_REPLACE (src);
260
261  GST_DEBUG_OBJECT (replace, "alloc");
262
263  return GST_FLOW_OK;
264}
265
266/* ask the subclass to fill the buffer with data from offset and size */
267static GstFlowReturn
268gst_replace_fill (GstBaseSrc * src, guint64 offset, guint size, GstBuffer * buf)
269{
270  GstReplace *replace = GST_REPLACE (src);
271
272  GST_DEBUG_OBJECT (replace, "fill");
273
274  return GST_FLOW_OK;
275}
276% end
277