|
1 /* GStreamer |
|
2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
|
3 * 2000 Wim Taymans <wtay@chello.be> |
|
4 * |
|
5 * gstbasesink.h: |
|
6 * |
|
7 * This library is free software; you can redistribute it and/or |
|
8 * modify it under the terms of the GNU Library General Public |
|
9 * License as published by the Free Software Foundation; either |
|
10 * version 2 of the License, or (at your option) any later version. |
|
11 * |
|
12 * This library is distributed in the hope that it will be useful, |
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 * Library General Public License for more details. |
|
16 * |
|
17 * You should have received a copy of the GNU Library General Public |
|
18 * License along with this library; if not, write to the |
|
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
20 * Boston, MA 02111-1307, USA. |
|
21 */ |
|
22 |
|
23 #ifndef __GST_BASE_SINK_H__ |
|
24 #define __GST_BASE_SINK_H__ |
|
25 |
|
26 #include <gst/gst.h> |
|
27 |
|
28 G_BEGIN_DECLS |
|
29 |
|
30 |
|
31 #define GST_TYPE_BASE_SINK (gst_base_sink_get_type()) |
|
32 #define GST_BASE_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_SINK,GstBaseSink)) |
|
33 #define GST_BASE_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_SINK,GstBaseSinkClass)) |
|
34 #define GST_BASE_SINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_SINK, GstBaseSinkClass)) |
|
35 #define GST_IS_BASE_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_SINK)) |
|
36 #define GST_IS_BASE_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_SINK)) |
|
37 #define GST_BASE_SINK_CAST(obj) ((GstBaseSink *) (obj)) |
|
38 |
|
39 /** |
|
40 * GST_BASE_SINK_PAD: |
|
41 * @obj: base sink instance |
|
42 * |
|
43 * Gives the pointer to the #GstPad object of the element. |
|
44 */ |
|
45 #define GST_BASE_SINK_PAD(obj) (GST_BASE_SINK_CAST (obj)->sinkpad) |
|
46 |
|
47 typedef struct _GstBaseSink GstBaseSink; |
|
48 typedef struct _GstBaseSinkClass GstBaseSinkClass; |
|
49 typedef struct _GstBaseSinkPrivate GstBaseSinkPrivate; |
|
50 |
|
51 /** |
|
52 * GstBaseSink: |
|
53 * @element: the parent element. |
|
54 * |
|
55 * The opaque #GstBaseSink data structure. |
|
56 */ |
|
57 struct _GstBaseSink { |
|
58 GstElement element; |
|
59 |
|
60 /*< protected >*/ |
|
61 GstPad *sinkpad; |
|
62 GstActivateMode pad_mode; |
|
63 |
|
64 /*< protected >*/ /* with LOCK */ |
|
65 guint64 offset; |
|
66 gboolean can_activate_pull; |
|
67 gboolean can_activate_push; |
|
68 |
|
69 /*< protected >*/ /* with PREROLL_LOCK */ |
|
70 GQueue *preroll_queue; |
|
71 gint preroll_queue_max_len; |
|
72 gint preroll_queued; |
|
73 gint buffers_queued; |
|
74 gint events_queued; |
|
75 gboolean eos; |
|
76 gboolean eos_queued; |
|
77 gboolean need_preroll; |
|
78 gboolean have_preroll; |
|
79 gboolean playing_async; |
|
80 |
|
81 /*< protected >*/ /* with STREAM_LOCK */ |
|
82 gboolean have_newsegment; |
|
83 GstSegment segment; |
|
84 |
|
85 /*< private >*/ /* with LOCK */ |
|
86 GstClockID clock_id; |
|
87 GstClockTime end_time; |
|
88 gboolean sync; |
|
89 gboolean flushing; |
|
90 |
|
91 /*< private >*/ |
|
92 union { |
|
93 struct { |
|
94 /* segment used for clipping incomming buffers */ |
|
95 GstSegment *clip_segment; |
|
96 /* max amount of time a buffer can be late, -1 no limit. */ |
|
97 gint64 max_lateness; |
|
98 } ABI; |
|
99 gpointer _gst_reserved[GST_PADDING_LARGE - 1]; |
|
100 } abidata; |
|
101 |
|
102 GstBaseSinkPrivate *priv; |
|
103 }; |
|
104 |
|
105 /** |
|
106 * GstBaseSinkClass: |
|
107 * @parent_class: Element parent class |
|
108 * @get_caps: Called to get sink pad caps from the subclass |
|
109 * @set_caps: Notify subclass of changed caps |
|
110 * @buffer_alloc: Subclasses can override to perform custom buffer allocations |
|
111 * @get_times: Called to get the start and end times for synchronising |
|
112 * the passed buffer to the clock |
|
113 * @start: Start processing. Ideal for opening resources in the subclass |
|
114 * @stop: Stop processing. Subclasses should use this to close resources. |
|
115 * @unlock: Unlock any pending access to the resource. Subclasses should |
|
116 * unblock any blocked function ASAP |
|
117 * @unlock_stop: Clear the previous unlock request. Subclasses should clear |
|
118 * any state they set during unlock(), such as clearing command queues. |
|
119 * @event: Override this to handle events arriving on the sink pad |
|
120 * @preroll: Called to present the preroll buffer if desired |
|
121 * @render: Called when a buffer should be presented or output, at the |
|
122 * correct moment if the #GstBaseSink has been set to sync to the clock. |
|
123 * @async_play: Subclasses should override this when they need to perform |
|
124 * special processing when changing to the PLAYING state asynchronously. |
|
125 * Called with the OBJECT_LOCK held. |
|
126 * @activate_pull: Subclasses should override this when they can provide an |
|
127 * alternate method of spawning a thread to drive the pipeline in pull mode. |
|
128 * Should start or stop the pulling thread, depending on the value of the |
|
129 * "active" argument. Called after actually activating the sink pad in pull |
|
130 * mode. The default implementation starts a task on the sink pad. |
|
131 * @fixate: Only useful in pull mode, this vmethod will be called in response to |
|
132 * gst_pad_fixate_caps() being called on the sink pad. Implement if you have |
|
133 * ideas about what should be the default values for the caps you support. |
|
134 * |
|
135 * Subclasses can override any of the available virtual methods or not, as |
|
136 * needed. At the minimum, the @render method should be overridden to |
|
137 * output/present buffers. |
|
138 */ |
|
139 struct _GstBaseSinkClass { |
|
140 GstElementClass parent_class; |
|
141 |
|
142 /* get caps from subclass */ |
|
143 GstCaps* (*get_caps) (GstBaseSink *sink); |
|
144 /* notify subclass of new caps */ |
|
145 gboolean (*set_caps) (GstBaseSink *sink, GstCaps *caps); |
|
146 |
|
147 /* allocate a new buffer with given caps */ |
|
148 GstFlowReturn (*buffer_alloc) (GstBaseSink *sink, guint64 offset, guint size, |
|
149 GstCaps *caps, GstBuffer **buf); |
|
150 |
|
151 /* get the start and end times for syncing on this buffer */ |
|
152 void (*get_times) (GstBaseSink *sink, GstBuffer *buffer, |
|
153 GstClockTime *start, GstClockTime *end); |
|
154 |
|
155 /* start and stop processing, ideal for opening/closing the resource */ |
|
156 gboolean (*start) (GstBaseSink *sink); |
|
157 gboolean (*stop) (GstBaseSink *sink); |
|
158 |
|
159 /* unlock any pending access to the resource. subclasses should unlock |
|
160 * any function ASAP. */ |
|
161 gboolean (*unlock) (GstBaseSink *sink); |
|
162 |
|
163 /* notify subclass of event, preroll buffer or real buffer */ |
|
164 gboolean (*event) (GstBaseSink *sink, GstEvent *event); |
|
165 GstFlowReturn (*preroll) (GstBaseSink *sink, GstBuffer *buffer); |
|
166 GstFlowReturn (*render) (GstBaseSink *sink, GstBuffer *buffer); |
|
167 |
|
168 /* ABI additions */ |
|
169 |
|
170 /* when an ASYNC state change to PLAYING happens */ /* with LOCK */ |
|
171 GstStateChangeReturn (*async_play) (GstBaseSink *sink); |
|
172 |
|
173 /* start or stop a pulling thread */ |
|
174 gboolean (*activate_pull)(GstBaseSink *sink, gboolean active); |
|
175 |
|
176 /* fixate sink caps during pull-mode negotiation */ |
|
177 void (*fixate) (GstBaseSink *sink, GstCaps *caps); |
|
178 |
|
179 /* Clear a previously indicated unlock request not that unlocking is |
|
180 * complete. Sub-classes should clear any command queue or indicator they |
|
181 * set during unlock */ |
|
182 gboolean (*unlock_stop) (GstBaseSink *sink); |
|
183 |
|
184 /*< private >*/ |
|
185 gpointer _gst_reserved[GST_PADDING_LARGE-4]; |
|
186 }; |
|
187 #ifdef __SYMBIAN32__ |
|
188 IMPORT_C |
|
189 #endif |
|
190 |
|
191 |
|
192 GType gst_base_sink_get_type(void); |
|
193 #ifdef __SYMBIAN32__ |
|
194 IMPORT_C |
|
195 #endif |
|
196 |
|
197 |
|
198 GstFlowReturn gst_base_sink_wait_preroll (GstBaseSink *sink); |
|
199 |
|
200 /* synchronizing against the clock */ |
|
201 #ifdef __SYMBIAN32__ |
|
202 IMPORT_C |
|
203 #endif |
|
204 |
|
205 void gst_base_sink_set_sync (GstBaseSink *sink, gboolean sync); |
|
206 #ifdef __SYMBIAN32__ |
|
207 IMPORT_C |
|
208 #endif |
|
209 |
|
210 gboolean gst_base_sink_get_sync (GstBaseSink *sink); |
|
211 |
|
212 /* dropping late buffers */ |
|
213 #ifdef __SYMBIAN32__ |
|
214 IMPORT_C |
|
215 #endif |
|
216 |
|
217 void gst_base_sink_set_max_lateness (GstBaseSink *sink, gint64 max_lateness); |
|
218 #ifdef __SYMBIAN32__ |
|
219 IMPORT_C |
|
220 #endif |
|
221 |
|
222 gint64 gst_base_sink_get_max_lateness (GstBaseSink *sink); |
|
223 |
|
224 /* performing QoS */ |
|
225 #ifdef __SYMBIAN32__ |
|
226 IMPORT_C |
|
227 #endif |
|
228 |
|
229 void gst_base_sink_set_qos_enabled (GstBaseSink *sink, gboolean enabled); |
|
230 #ifdef __SYMBIAN32__ |
|
231 IMPORT_C |
|
232 #endif |
|
233 |
|
234 gboolean gst_base_sink_is_qos_enabled (GstBaseSink *sink); |
|
235 |
|
236 /* doing async state changes */ |
|
237 #ifdef __SYMBIAN32__ |
|
238 IMPORT_C |
|
239 #endif |
|
240 |
|
241 void gst_base_sink_set_async_enabled (GstBaseSink *sink, gboolean enabled); |
|
242 #ifdef __SYMBIAN32__ |
|
243 IMPORT_C |
|
244 #endif |
|
245 |
|
246 gboolean gst_base_sink_is_async_enabled (GstBaseSink *sink); |
|
247 |
|
248 /* tuning synchronisation */ |
|
249 #ifdef __SYMBIAN32__ |
|
250 IMPORT_C |
|
251 #endif |
|
252 |
|
253 void gst_base_sink_set_ts_offset (GstBaseSink *sink, GstClockTimeDiff offset); |
|
254 #ifdef __SYMBIAN32__ |
|
255 IMPORT_C |
|
256 #endif |
|
257 |
|
258 GstClockTimeDiff gst_base_sink_get_ts_offset (GstBaseSink *sink); |
|
259 |
|
260 /* last buffer */ |
|
261 #ifdef __SYMBIAN32__ |
|
262 IMPORT_C |
|
263 #endif |
|
264 |
|
265 GstBuffer * gst_base_sink_get_last_buffer (GstBaseSink *sink); |
|
266 |
|
267 /* latency */ |
|
268 #ifdef __SYMBIAN32__ |
|
269 IMPORT_C |
|
270 #endif |
|
271 |
|
272 gboolean gst_base_sink_query_latency (GstBaseSink *sink, gboolean *live, gboolean *upstream_live, |
|
273 GstClockTime *min_latency, GstClockTime *max_latency); |
|
274 #ifdef __SYMBIAN32__ |
|
275 IMPORT_C |
|
276 #endif |
|
277 |
|
278 GstClockTime gst_base_sink_get_latency (GstBaseSink *sink); |
|
279 #ifdef __SYMBIAN32__ |
|
280 IMPORT_C |
|
281 #endif |
|
282 |
|
283 |
|
284 GstFlowReturn gst_base_sink_wait_eos (GstBaseSink *sink, GstClockTime time, |
|
285 GstClockTimeDiff *jitter); |
|
286 |
|
287 G_END_DECLS |
|
288 |
|
289 #endif /* __GST_BASE_SINK_H__ */ |