|
1 /* GStreamer |
|
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
|
3 * 2000 Wim Taymans <wtay@chello.be> |
|
4 * 2005 Wim Taymans <wim@fluendo.com> |
|
5 * |
|
6 * gstbasesrc.h: |
|
7 * |
|
8 * This library is free software; you can redistribute it and/or |
|
9 * modify it under the terms of the GNU Library General Public |
|
10 * License as published by the Free Software Foundation; either |
|
11 * version 2 of the License, or (at your option) any later version. |
|
12 * |
|
13 * This library is distributed in the hope that it will be useful, |
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 * Library General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU Library General Public |
|
19 * License along with this library; if not, write to the |
|
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
21 * Boston, MA 02111-1307, USA. |
|
22 */ |
|
23 |
|
24 #ifndef __GST_BASE_SRC_H__ |
|
25 #define __GST_BASE_SRC_H__ |
|
26 |
|
27 #include <gst/gst.h> |
|
28 |
|
29 G_BEGIN_DECLS |
|
30 |
|
31 #define GST_TYPE_BASE_SRC (gst_base_src_get_type()) |
|
32 #define GST_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_SRC,GstBaseSrc)) |
|
33 #define GST_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_SRC,GstBaseSrcClass)) |
|
34 #define GST_BASE_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_SRC, GstBaseSrcClass)) |
|
35 #define GST_IS_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_SRC)) |
|
36 #define GST_IS_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_SRC)) |
|
37 #define GST_BASE_SRC_CAST(obj) ((GstBaseSrc *)(obj)) |
|
38 |
|
39 /** |
|
40 * GstBaseSrcFlags: |
|
41 * @GST_BASE_SRC_STARTED: has source been started |
|
42 * @GST_BASE_SRC_FLAG_LAST: offset to define more flags |
|
43 * |
|
44 * The #GstElement flags that a basesrc element may have. |
|
45 */ |
|
46 typedef enum { |
|
47 GST_BASE_SRC_STARTED = (GST_ELEMENT_FLAG_LAST << 0), |
|
48 /* padding */ |
|
49 GST_BASE_SRC_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2) |
|
50 } GstBaseSrcFlags; |
|
51 |
|
52 typedef struct _GstBaseSrc GstBaseSrc; |
|
53 typedef struct _GstBaseSrcClass GstBaseSrcClass; |
|
54 typedef struct _GstBaseSrcPrivate GstBaseSrcPrivate; |
|
55 |
|
56 /** |
|
57 * GST_BASE_SRC_PAD: |
|
58 * @obj: base source instance |
|
59 * |
|
60 * Gives the pointer to the #GstPad object of the element. |
|
61 */ |
|
62 #define GST_BASE_SRC_PAD(obj) (GST_BASE_SRC_CAST (obj)->srcpad) |
|
63 |
|
64 |
|
65 /** |
|
66 * GstBaseSrc: |
|
67 * @element: the parent element. |
|
68 * |
|
69 * The opaque #GstBaseSrc data structure. |
|
70 */ |
|
71 struct _GstBaseSrc { |
|
72 GstElement element; |
|
73 |
|
74 /*< protected >*/ |
|
75 GstPad *srcpad; |
|
76 |
|
77 /* available to subclass implementations */ |
|
78 /* MT-protected (with LIVE_LOCK) */ |
|
79 GMutex *live_lock; |
|
80 GCond *live_cond; |
|
81 gboolean is_live; |
|
82 gboolean live_running; |
|
83 |
|
84 /* MT-protected (with LOCK) */ |
|
85 gint blocksize; /* size of buffers when operating push based */ |
|
86 gboolean can_activate_push; /* some scheduling properties */ |
|
87 GstActivateMode pad_mode; |
|
88 gboolean seekable; |
|
89 gboolean random_access; |
|
90 |
|
91 GstClockID clock_id; /* for syncing */ |
|
92 GstClockTime end_time; |
|
93 |
|
94 /* MT-protected (with STREAM_LOCK) */ |
|
95 GstSegment segment; |
|
96 gboolean need_newsegment; |
|
97 |
|
98 guint64 offset; /* current offset in the resource, unused */ |
|
99 guint64 size; /* total size of the resource, unused */ |
|
100 |
|
101 gint num_buffers; |
|
102 gint num_buffers_left; |
|
103 |
|
104 /*< private >*/ |
|
105 union { |
|
106 struct { |
|
107 /* FIXME: those fields should be moved into the private struct */ |
|
108 gboolean typefind; |
|
109 gboolean running; |
|
110 GstEvent *pending_seek; |
|
111 } ABI; |
|
112 gpointer _gst_reserved[GST_PADDING_LARGE-1]; |
|
113 } data; |
|
114 |
|
115 GstBaseSrcPrivate *priv; |
|
116 }; |
|
117 |
|
118 /** |
|
119 * GstBaseSrcClass: |
|
120 * @parent_class: Element parent class |
|
121 * @get_caps: Called to get the caps to report |
|
122 * @set_caps: Notify subclass of changed output caps |
|
123 * @negotiate: Negotiated the caps with the peer. |
|
124 * @newsegment: Generate and send a new_segment event (UNUSED) |
|
125 * @start: Start processing. Subclasses should open resources and prepare |
|
126 * to produce data. |
|
127 * @stop: Stop processing. Subclasses should use this to close resources. |
|
128 * @get_times: Given a buffer, return the start and stop time when it |
|
129 * should be pushed out. The base class will sync on the clock using |
|
130 * these times. |
|
131 * @get_size: Return the total size of the resource, in the configured format. |
|
132 * @is_seekable: Check if the source can seek |
|
133 * @unlock: Unlock any pending access to the resource. Subclasses should |
|
134 * unblock any blocked function ASAP |
|
135 * @unlock_stop: Clear the previous unlock request. Subclasses should clear |
|
136 * any state they set during unlock(), such as clearing command queues. |
|
137 * @event: Override this to implement custom event handling. |
|
138 * @create: Ask the subclass to create a buffer with offset and size. |
|
139 * @do_seek: Perform seeking on the resource to the indicated segment. |
|
140 * @prepare_seek_segment: Prepare the GstSegment that will be passed to the |
|
141 * do_seek vmethod for executing a seek request. Sub-classes should override |
|
142 * this if they support seeking in formats other than the configured native |
|
143 * format. By default, it tries to convert the seek arguments to the |
|
144 * configured native format and prepare a segment in that format. |
|
145 * Since: 0.10.13 |
|
146 * @query: Handle a requested query. |
|
147 * @check_get_range: Check whether the source would support pull-based |
|
148 * operation if it were to be opened now. This vfunc is optional, but |
|
149 * should be implemented if possible to avoid unnecessary start/stop |
|
150 * cycles. The default implementation will open and close the resource |
|
151 * to find out whether get_range is supported, and that is usually |
|
152 * undesirable. |
|
153 * @fixate: Called during negotation if caps need fixating. Implement instead of |
|
154 * setting a fixate function on the source pad. |
|
155 * |
|
156 * Subclasses can override any of the available virtual methods or not, as |
|
157 * needed. At the minimum, the @create method should be overridden to produce |
|
158 * buffers. |
|
159 */ |
|
160 struct _GstBaseSrcClass { |
|
161 GstElementClass parent_class; |
|
162 |
|
163 /*< public >*/ |
|
164 /* virtual methods for subclasses */ |
|
165 |
|
166 /* get caps from subclass */ |
|
167 GstCaps* (*get_caps) (GstBaseSrc *src); |
|
168 /* notify the subclass of new caps */ |
|
169 gboolean (*set_caps) (GstBaseSrc *src, GstCaps *caps); |
|
170 |
|
171 /* decide on caps */ |
|
172 gboolean (*negotiate) (GstBaseSrc *src); |
|
173 |
|
174 /* generate and send a newsegment (UNUSED) */ |
|
175 gboolean (*newsegment) (GstBaseSrc *src); |
|
176 |
|
177 /* start and stop processing, ideal for opening/closing the resource */ |
|
178 gboolean (*start) (GstBaseSrc *src); |
|
179 gboolean (*stop) (GstBaseSrc *src); |
|
180 |
|
181 /* given a buffer, return start and stop time when it should be pushed |
|
182 * out. The base class will sync on the clock using these times. */ |
|
183 void (*get_times) (GstBaseSrc *src, GstBuffer *buffer, |
|
184 GstClockTime *start, GstClockTime *end); |
|
185 |
|
186 /* get the total size of the resource in bytes */ |
|
187 gboolean (*get_size) (GstBaseSrc *src, guint64 *size); |
|
188 |
|
189 /* check if the resource is seekable */ |
|
190 gboolean (*is_seekable) (GstBaseSrc *src); |
|
191 /* unlock any pending access to the resource. subclasses should unlock |
|
192 * any function ASAP. */ |
|
193 gboolean (*unlock) (GstBaseSrc *src); |
|
194 |
|
195 /* notify subclasses of an event */ |
|
196 gboolean (*event) (GstBaseSrc *src, GstEvent *event); |
|
197 |
|
198 /* ask the subclass to create a buffer with offset and size */ |
|
199 GstFlowReturn (*create) (GstBaseSrc *src, guint64 offset, guint size, |
|
200 GstBuffer **buf); |
|
201 |
|
202 /* additions that change padding... */ |
|
203 /* notify subclasses of a seek */ |
|
204 gboolean (*do_seek) (GstBaseSrc *src, GstSegment *segment); |
|
205 /* notify subclasses of a query */ |
|
206 gboolean (*query) (GstBaseSrc *src, GstQuery *query); |
|
207 |
|
208 /* check whether the source would support pull-based operation if |
|
209 * it were to be opened now. This vfunc is optional, but should be |
|
210 * implemented if possible to avoid unnecessary start/stop cycles. |
|
211 * The default implementation will open and close the resource to |
|
212 * find out whether get_range is supported and that is usually |
|
213 * undesirable. */ |
|
214 gboolean (*check_get_range) (GstBaseSrc *src); |
|
215 |
|
216 /* called if, in negotation, caps need fixating */ |
|
217 void (*fixate) (GstBaseSrc *src, GstCaps *caps); |
|
218 |
|
219 /* Clear any pending unlock request, as we succeeded in unlocking */ |
|
220 gboolean (*unlock_stop) (GstBaseSrc *src); |
|
221 |
|
222 /* Prepare the segment on which to perform do_seek(), converting to the |
|
223 * current basesrc format. */ |
|
224 gboolean (*prepare_seek_segment) (GstBaseSrc *src, GstEvent *seek, |
|
225 GstSegment *segment); |
|
226 |
|
227 /*< private >*/ |
|
228 gpointer _gst_reserved[GST_PADDING_LARGE - 6]; |
|
229 }; |
|
230 #ifdef __SYMBIAN32__ |
|
231 IMPORT_C |
|
232 #endif |
|
233 |
|
234 |
|
235 GType gst_base_src_get_type (void); |
|
236 #ifdef __SYMBIAN32__ |
|
237 IMPORT_C |
|
238 #endif |
|
239 |
|
240 |
|
241 GstFlowReturn gst_base_src_wait_playing (GstBaseSrc *src); |
|
242 #ifdef __SYMBIAN32__ |
|
243 IMPORT_C |
|
244 #endif |
|
245 |
|
246 |
|
247 void gst_base_src_set_live (GstBaseSrc *src, gboolean live); |
|
248 #ifdef __SYMBIAN32__ |
|
249 IMPORT_C |
|
250 #endif |
|
251 |
|
252 gboolean gst_base_src_is_live (GstBaseSrc *src); |
|
253 #ifdef __SYMBIAN32__ |
|
254 IMPORT_C |
|
255 #endif |
|
256 |
|
257 |
|
258 void gst_base_src_set_format (GstBaseSrc *src, GstFormat format); |
|
259 #ifdef __SYMBIAN32__ |
|
260 IMPORT_C |
|
261 #endif |
|
262 |
|
263 |
|
264 gboolean gst_base_src_query_latency (GstBaseSrc *src, gboolean * live, |
|
265 GstClockTime * min_latency, |
|
266 GstClockTime * max_latency); |
|
267 #ifdef __SYMBIAN32__ |
|
268 IMPORT_C |
|
269 #endif |
|
270 |
|
271 |
|
272 void gst_base_src_set_do_timestamp (GstBaseSrc *src, gboolean live); |
|
273 #ifdef __SYMBIAN32__ |
|
274 IMPORT_C |
|
275 #endif |
|
276 |
|
277 gboolean gst_base_src_get_do_timestamp (GstBaseSrc *src); |
|
278 |
|
279 G_END_DECLS |
|
280 |
|
281 #endif /* __GST_BASE_SRC_H__ */ |