]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gstreamer0-10.git/blob - gst/gstelement.h
docs: gst: more gobject introspection annotations
[glsdk/gstreamer0-10.git] / gst / gstelement.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *               2000,2004 Wim Taymans <wim@fluendo.com>
4  *
5  * gstelement.h: Header for GstElement
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  */
24 #ifndef __GST_ELEMENT_H__
25 #define __GST_ELEMENT_H__
27 /* gstelement.h and gstelementfactory.h include eachother */
28 typedef struct _GstElement GstElement;
29 typedef struct _GstElementClass GstElementClass;
31 /* gstmessage.h needs State */
32 /**
33  * GstState:
34  * @GST_STATE_VOID_PENDING: no pending state.
35  * @GST_STATE_NULL        : the NULL state or initial state of an element.
36  * @GST_STATE_READY       : the element is ready to go to PAUSED.
37  * @GST_STATE_PAUSED      : the element is PAUSED, it is ready to accept and
38  *                          process data. Sink elements however only accept one
39  *                          buffer and then block.
40  * @GST_STATE_PLAYING     : the element is PLAYING, the #GstClock is running and
41  *                          the data is flowing.
42  *
43  * The possible states an element can be in. States can be changed using
44  * gst_element_set_state() and checked using gst_element_get_state().
45  */
46 typedef enum {
47   GST_STATE_VOID_PENDING        = 0,
48   GST_STATE_NULL                = 1,
49   GST_STATE_READY               = 2,
50   GST_STATE_PAUSED              = 3,
51   GST_STATE_PLAYING             = 4
52 } GstState;
55 #include <gst/gstconfig.h>
56 #include <gst/gstobject.h>
57 #include <gst/gstpad.h>
58 #include <gst/gstbus.h>
59 #include <gst/gstclock.h>
60 #include <gst/gstelementfactory.h>
61 #include <gst/gstplugin.h>
62 #include <gst/gstpluginfeature.h>
63 #include <gst/gstindex.h>
64 #include <gst/gstindexfactory.h>
65 #include <gst/gstiterator.h>
66 #include <gst/gstmessage.h>
67 #include <gst/gsttaglist.h>
69 G_BEGIN_DECLS
71 #define GST_TYPE_ELEMENT                (gst_element_get_type ())
72 #define GST_IS_ELEMENT(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_ELEMENT))
73 #define GST_IS_ELEMENT_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_ELEMENT))
74 #define GST_ELEMENT_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ELEMENT, GstElementClass))
75 #define GST_ELEMENT(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_ELEMENT, GstElement))
76 #define GST_ELEMENT_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_ELEMENT, GstElementClass))
77 #define GST_ELEMENT_CAST(obj)           ((GstElement*)(obj))
79 /**
80  * GstStateChangeReturn:
81  * @GST_STATE_CHANGE_FAILURE   : the state change failed
82  * @GST_STATE_CHANGE_SUCCESS   : the state change succeeded
83  * @GST_STATE_CHANGE_ASYNC     : the state change will happen asynchronously
84  * @GST_STATE_CHANGE_NO_PREROLL: the state change succeeded but the element
85  *                               cannot produce data in %GST_STATE_PAUSED.
86  *                               This typically happens with live sources.
87  *
88  * The possible return values from a state change function. Only
89  * @GST_STATE_CHANGE_FAILURE is a real failure.
90  */
91 typedef enum {
92   GST_STATE_CHANGE_FAILURE             = 0,
93   GST_STATE_CHANGE_SUCCESS             = 1,
94   GST_STATE_CHANGE_ASYNC               = 2,
95   GST_STATE_CHANGE_NO_PREROLL          = 3
96 } GstStateChangeReturn;
98 /* NOTE: this probably should be done with an #ifdef to decide
99  * whether to safe-cast or to just do the non-checking cast.
100  */
102 /**
103  * GST_STATE:
104  * @elem: a #GstElement to return state for.
105  *
106  * This macro returns the current #GstState of the element.
107  */
108 #define GST_STATE(elem)                 (GST_ELEMENT_CAST(elem)->current_state)
110 /**
111  * GST_STATE_NEXT:
112  * @elem: a #GstElement to return the next state for.
113  *
114  * This macro returns the next #GstState of the element.
115  */
116 #define GST_STATE_NEXT(elem)            (GST_ELEMENT_CAST(elem)->next_state)
118 /**
119  * GST_STATE_PENDING:
120  * @elem: a #GstElement to return the pending state for.
121  *
122  * This macro returns the currently pending #GstState of the element.
123  */
124 #define GST_STATE_PENDING(elem)         (GST_ELEMENT_CAST(elem)->pending_state)
126 /**
127  * GST_STATE_TARGET:
128  * @elem: a #GstElement to return the target state for.
129  *
130  * This macro returns the target #GstState of the element.
131  *
132  * Since: 0.10.13
133  */
134 #define GST_STATE_TARGET(elem)          (GST_ELEMENT_CAST(elem)->abidata.ABI.target_state)
136 /**
137  * GST_STATE_RETURN:
138  * @elem: a #GstElement to return the last state result for.
139  *
140  * This macro returns the last #GstStateChangeReturn value.
141  */
142 #define GST_STATE_RETURN(elem)          (GST_ELEMENT_CAST(elem)->last_return)
144 #define __GST_SIGN(val)                 ((val) < 0 ? -1 : ((val) > 0 ? 1 : 0))
145 /**
146  * GST_STATE_GET_NEXT:
147  * @cur: A starting #GstState
148  * @pending: A target #GstState
149  *
150  * Given a current state @cur and a target state @pending, calculate the next (intermediate)
151  * #GstState.
152  */
153 #define GST_STATE_GET_NEXT(cur,pending)         ((cur) + __GST_SIGN ((gint)(pending) - (gint)(cur)))
154 /**
155  * GST_STATE_TRANSITION:
156  * @cur: A current state
157  * @next: A next state
158  *
159  * Given a current state @cur and a next state @next, calculate the associated
160  * #GstStateChange transition.
161  */
162 #define GST_STATE_TRANSITION(cur,next)          ((GstStateChange)(((cur)<<3)|(next)))
163 /**
164  * GST_STATE_TRANSITION_CURRENT:
165  * @trans: A #GstStateChange
166  *
167  * Given a state transition @trans, extract the current #GstState.
168  */
169 #define GST_STATE_TRANSITION_CURRENT(trans)     ((GstState)((trans)>>3))
170 /**
171  * GST_STATE_TRANSITION_NEXT:
172  * @trans: A #GstStateChange
173  *
174  * Given a state transition @trans, extract the next #GstState.
175  */
176 #define GST_STATE_TRANSITION_NEXT(trans)        ((GstState)((trans)&0x7))
178 /**
179  * GstStateChange:
180  * @GST_STATE_CHANGE_NULL_TO_READY    : state change from NULL to READY.
181  * <itemizedlist>
182  *   <listitem><para>
183  *     The element must check if the resources it needs are available. Device
184  *     sinks and -sources typically try to probe the device to constrain their
185  *     caps.
186  *   </para></listitem>
187  *   <listitem><para>
188  *     The element opens the device (in case feature need to be probed).
189  *   </para></listitem>
190  * </itemizedlist>
191  * @GST_STATE_CHANGE_READY_TO_PAUSED  : state change from READY to PAUSED.
192  * <itemizedlist>
193  *   <listitem><para>
194  *     The element pads are activated in order to receive data in PAUSED.
195  *     Streaming threads are started.
196  *   </para></listitem>
197  *   <listitem><para>
198  *     Some elements might need to return ASYNC and complete the state change
199  *     when they have enough information. It is a requirement for sinks to
200  *     return ASYNC and complete the state change when they receive the first
201  *     buffer or EOS event (preroll). Sinks also block the dataflow when in
202  *     PAUSED.
203  *   </para></listitem>
204  *   <listitem><para>
205  *     A pipeline resets the running_time to 0.
206  *   </para></listitem>
207  *   <listitem><para>
208  *     Live sources return NO_PREROLL and don't generate data.
209  *   </para></listitem>
210  * </itemizedlist>
211  * @GST_STATE_CHANGE_PAUSED_TO_PLAYING: state change from PAUSED to PLAYING.
212  * <itemizedlist>
213  *   <listitem><para>
214  *     Most elements ignore this state change.
215  *   </para></listitem>
216  *   <listitem><para>
217  *     The pipeline selects a clock and distributes this to all the children
218  *     before setting them to PLAYING. This means that it is only alowed to
219  *     synchronize on the clock in the PLAYING state.
220  *   </para></listitem>
221  *   <listitem><para>
222  *     The pipeline uses the clock and the running_time to calculate the
223  *     base_time. The base_time is distributed to all children when performing
224  *     the state change.
225  *   </para></listitem>
226  *   <listitem><para>
227  *     Sink elements stop blocking on the preroll buffer or event and start
228  *     rendering the data.
229  *   </para></listitem>
230  *   <listitem><para>
231  *     Sinks can post the EOS message in the PLAYING state. It is not allowed to
232  *     post EOS when not in the PLAYING state.
233  *   </para></listitem>
234  *   <listitem><para>
235  *     While streaming in PAUSED or PLAYING elements can create and remove
236  *     sometimes pads.
237  *   </para></listitem>
238  *   <listitem><para>
239  *     Live sources start generating data and return SUCCESS.
240  *   </para></listitem>
241  * </itemizedlist>
242  * @GST_STATE_CHANGE_PLAYING_TO_PAUSED: state change from PLAYING to PAUSED.
243  * <itemizedlist>
244  *   <listitem><para>
245  *     Most elements ignore this state change.
246  *   </para></listitem>
247  *   <listitem><para>
248  *     The pipeline calculates the running_time based on the last selected clock
249  *     and the base_time. It stores this information to continue playback when
250  *     going back to the PLAYING state.
251  *   </para></listitem>
252  *   <listitem><para>
253  *     Sinks unblock any clock wait calls.
254  *   </para></listitem>
255  *   <listitem><para>
256  *     When a sink does not have a pending buffer to play, it returns ASYNC from
257  *     this state change and completes the state change when it receives a new
258  *     buffer or an EOS event.
259  *   </para></listitem>
260  *   <listitem><para>
261  *     Any queued EOS messages are removed since they will be reposted when going
262  *     back to the PLAYING state. The EOS messages are queued in GstBins.
263  *   </para></listitem>
264  *   <listitem><para>
265  *     Live sources stop generating data and return NO_PREROLL.
266  *   </para></listitem>
267  * </itemizedlist>
268  * @GST_STATE_CHANGE_PAUSED_TO_READY  : state change from PAUSED to READY.
269  * <itemizedlist>
270  *   <listitem><para>
271  *     Sinks unblock any waits in the preroll.
272  *   </para></listitem>
273  *   <listitem><para>
274  *     Elements unblock any waits on devices
275  *   </para></listitem>
276  *   <listitem><para>
277  *     Chain or get_range functions return WRONG_STATE.
278  *   </para></listitem>
279  *   <listitem><para>
280  *     The element pads are deactivated so that streaming becomes impossible and
281  *     all streaming threads are stopped.
282  *   </para></listitem>
283  *   <listitem><para>
284  *     The sink forgets all negotiated formats
285  *   </para></listitem>
286  *   <listitem><para>
287  *     Elements remove all sometimes pads
288  *   </para></listitem>
289  * </itemizedlist>
290  * @GST_STATE_CHANGE_READY_TO_NULL    : state change from READY to NULL.
291  * <itemizedlist>
292  *   <listitem><para>
293  *     Elements close devices
294  *   </para></listitem>
295  *   <listitem><para>
296  *     Elements reset any internal state.
297  *   </para></listitem>
298  * </itemizedlist>
299  *
300  * These are the different state changes an element goes through.
301  * %GST_STATE_NULL &rArr; %GST_STATE_PLAYING is called an upwards state change
302  * and %GST_STATE_PLAYING &rArr; %GST_STATE_NULL a downwards state change.
303  */
304 typedef enum /*< flags=0 >*/
306   GST_STATE_CHANGE_NULL_TO_READY        = (GST_STATE_NULL<<3) | GST_STATE_READY,
307   GST_STATE_CHANGE_READY_TO_PAUSED      = (GST_STATE_READY<<3) | GST_STATE_PAUSED,
308   GST_STATE_CHANGE_PAUSED_TO_PLAYING    = (GST_STATE_PAUSED<<3) | GST_STATE_PLAYING,
309   GST_STATE_CHANGE_PLAYING_TO_PAUSED    = (GST_STATE_PLAYING<<3) | GST_STATE_PAUSED,
310   GST_STATE_CHANGE_PAUSED_TO_READY      = (GST_STATE_PAUSED<<3) | GST_STATE_READY,
311   GST_STATE_CHANGE_READY_TO_NULL        = (GST_STATE_READY<<3) | GST_STATE_NULL
312 } GstStateChange;
314 /**
315  * GstElementFlags:
316  * @GST_ELEMENT_LOCKED_STATE: ignore state changes from parent
317  * @GST_ELEMENT_IS_SINK: the element is a sink
318  * @GST_ELEMENT_UNPARENTING: Child is being removed from the parent bin.
319  *  gst_bin_remove() on a child already being removed immediately returns FALSE
320  * @GST_ELEMENT_IS_SOURCE: the element is a source. Since 0.10.31
321  * @GST_ELEMENT_FLAG_LAST: offset to define more flags
322  *
323  * The standard flags that an element may have.
324  */
325 typedef enum
327   GST_ELEMENT_LOCKED_STATE      = (GST_OBJECT_FLAG_LAST << 0),
328   GST_ELEMENT_IS_SINK           = (GST_OBJECT_FLAG_LAST << 1),
329   GST_ELEMENT_UNPARENTING       = (GST_OBJECT_FLAG_LAST << 2),
330   GST_ELEMENT_IS_SOURCE         = (GST_OBJECT_FLAG_LAST << 3),
331   /* padding */
332   GST_ELEMENT_FLAG_LAST         = (GST_OBJECT_FLAG_LAST << 16)
333 } GstElementFlags;
335 /**
336  * GST_ELEMENT_IS_LOCKED_STATE:
337  * @elem: A #GstElement to query
338  *
339  * Check if the element is in the locked state and therefore will ignore state
340  * changes from its parent object.
341  */
342 #define GST_ELEMENT_IS_LOCKED_STATE(elem)        (GST_OBJECT_FLAG_IS_SET(elem,GST_ELEMENT_LOCKED_STATE))
344 /**
345  * GST_ELEMENT_NAME:
346  * @elem: A #GstElement to query
347  *
348  * Gets the name of this element. Use only in core as this is not
349  * ABI-compatible. Others use gst_element_get_name()
350  */
351 #define GST_ELEMENT_NAME(elem)                  (GST_OBJECT_NAME(elem))
353 /**
354  * GST_ELEMENT_PARENT:
355  * @elem: A #GstElement to query
356  *
357  * Get the parent object of this element.
358  */
359 #define GST_ELEMENT_PARENT(elem)                (GST_ELEMENT_CAST(GST_OBJECT_PARENT(elem)))
361 /**
362  * GST_ELEMENT_BUS:
363  * @elem: A #GstElement to query
364  *
365  * Get the message bus of this element.
366  */
367 #define GST_ELEMENT_BUS(elem)                   (GST_ELEMENT_CAST(elem)->bus)
369 /**
370  * GST_ELEMENT_CLOCK:
371  * @elem: A #GstElement to query
372  *
373  * Get the clock of this element
374  */
375 #define GST_ELEMENT_CLOCK(elem)                 (GST_ELEMENT_CAST(elem)->clock)
377 /**
378  * GST_ELEMENT_PADS:
379  * @elem: A #GstElement to query
380  *
381  * Get the pads of this elements.
382  */
383 #define GST_ELEMENT_PADS(elem)                  (GST_ELEMENT_CAST(elem)->pads)
385 /**
386  * GST_ELEMENT_START_TIME:
387  * @elem: a #GstElement to return the start time for.
388  *
389  * This macro returns the start_time of the @elem. The start_time is the
390  * running_time of the pipeline when the element went to PAUSED.
391  *
392  * Since: 0.10.24
393  */
394 #define GST_ELEMENT_START_TIME(elem)            (GST_ELEMENT_CAST(elem)->abidata.ABI.start_time)
396 /**
397  * GST_ELEMENT_ERROR:
398  * @el:     the element that generates the error
399  * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
400  * @code:   error code defined for that domain (see #gstreamer-GstGError)
401  * @text:   the message to display (format string and args enclosed in
402             parentheses)
403  * @debug:  debugging information for the message (format string and args
404             enclosed in parentheses)
405  *
406  * Utility function that elements can use in case they encountered a fatal
407  * data processing error. The pipeline will post an error message and the
408  * application will be requested to stop further media processing.
409  */
410 #define GST_ELEMENT_ERROR(el, domain, code, text, debug)                \
411 G_STMT_START {                                                          \
412   gchar *__txt = _gst_element_error_printf text;                        \
413   gchar *__dbg = _gst_element_error_printf debug;                       \
414   if (__txt)                                                            \
415     GST_WARNING_OBJECT (el, "error: %s", __txt);                        \
416   if (__dbg)                                                            \
417     GST_WARNING_OBJECT (el, "error: %s", __dbg);                        \
418   gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_ERROR,         \
419     GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code,        \
420     __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__);                    \
421 } G_STMT_END
423 /**
424  * GST_ELEMENT_WARNING:
425  * @el:     the element that generates the warning
426  * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
427  * @code:   error code defined for that domain (see #gstreamer-GstGError)
428  * @text:   the message to display (format string and args enclosed in
429             parentheses)
430  * @debug:  debugging information for the message (format string and args
431             enclosed in parentheses)
432  *
433  * Utility function that elements can use in case they encountered a non-fatal
434  * data processing problem. The pipeline will post a warning message and the
435  * application will be informed.
436  */
437 #define GST_ELEMENT_WARNING(el, domain, code, text, debug)              \
438 G_STMT_START {                                                          \
439   gchar *__txt = _gst_element_error_printf text;                        \
440   gchar *__dbg = _gst_element_error_printf debug;                       \
441   if (__txt)                                                            \
442     GST_WARNING_OBJECT (el, "warning: %s", __txt);                      \
443   if (__dbg)                                                            \
444     GST_WARNING_OBJECT (el, "warning: %s", __dbg);                      \
445   gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_WARNING,       \
446     GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code,        \
447   __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__);                      \
448 } G_STMT_END
450 /**
451  * GST_ELEMENT_INFO:
452  * @el:     the element that generates the information
453  * @domain: like CORE, LIBRARY, RESOURCE or STREAM (see #gstreamer-GstGError)
454  * @code:   error code defined for that domain (see #gstreamer-GstGError)
455  * @text:   the message to display (format string and args enclosed in
456             parentheses)
457  * @debug:  debugging information for the message (format string and args
458             enclosed in parentheses)
459  *
460  * Utility function that elements can use in case they want to inform
461  * the application of something noteworthy that is not an error.
462  * The pipeline will post a warning message and the
463  * application will be informed.
464  *
465  * Since: 0.10.12
466  */
467 #define GST_ELEMENT_INFO(el, domain, code, text, debug)                 \
468 G_STMT_START {                                                          \
469   gchar *__txt = _gst_element_error_printf text;                        \
470   gchar *__dbg = _gst_element_error_printf debug;                       \
471   if (__txt)                                                            \
472     GST_INFO_OBJECT (el, "info: %s", __txt);                            \
473   if (__dbg)                                                            \
474     GST_INFO_OBJECT (el, "info: %s", __dbg);                            \
475   gst_element_message_full (GST_ELEMENT(el), GST_MESSAGE_INFO,          \
476     GST_ ## domain ## _ERROR, GST_ ## domain ## _ERROR_ ## code,        \
477   __txt, __dbg, __FILE__, GST_FUNCTION, __LINE__);                      \
478 } G_STMT_END
480 /* the state change mutexes and conds */
481 /**
482  * GST_STATE_GET_LOCK:
483  * @elem:   a #GstElement
484  *
485  * Get a reference to the state lock of @elem.
486  * This lock is used by the core.  It is taken while getting or setting
487  * the state, during state changes, and while finalizing.
488  */
489 #define GST_STATE_GET_LOCK(elem)               (GST_ELEMENT_CAST(elem)->state_lock)
490 /**
491  * GST_STATE_GET_COND:
492  * @elem: a #GstElement
493  *
494  * Get the conditional used to signal the completion of a state change.
495  */
496 #define GST_STATE_GET_COND(elem)               (GST_ELEMENT_CAST(elem)->state_cond)
498 #define GST_STATE_LOCK(elem)                   g_static_rec_mutex_lock(GST_STATE_GET_LOCK(elem))
499 #define GST_STATE_TRYLOCK(elem)                g_static_rec_mutex_trylock(GST_STATE_GET_LOCK(elem))
500 #define GST_STATE_UNLOCK(elem)                 g_static_rec_mutex_unlock(GST_STATE_GET_LOCK(elem))
501 #define GST_STATE_UNLOCK_FULL(elem)            g_static_rec_mutex_unlock_full(GST_STATE_GET_LOCK(elem))
502 #define GST_STATE_LOCK_FULL(elem,t)            g_static_rec_mutex_lock_full(GST_STATE_GET_LOCK(elem), t)
503 #define GST_STATE_WAIT(elem)                   g_cond_wait (GST_STATE_GET_COND (elem), \
504                                                         GST_OBJECT_GET_LOCK (elem))
505 #define GST_STATE_TIMED_WAIT(elem, timeval)    g_cond_timed_wait (GST_STATE_GET_COND (elem), \
506                                                         GST_OBJECT_GET_LOCK (elem), timeval)
507 #define GST_STATE_SIGNAL(elem)                 g_cond_signal (GST_STATE_GET_COND (elem));
508 #define GST_STATE_BROADCAST(elem)              g_cond_broadcast (GST_STATE_GET_COND (elem));
510 /**
511  * GstElement:
512  * @state_lock: Used to serialize execution of gst_element_set_state()
513  * @state_cond: Used to signal completion of a state change
514  * @state_cookie: Used to detect concurrent execution of
515  * gst_element_set_state() and gst_element_get_state()
516  * @current_state: the current state of an element
517  * @next_state: the next state of an element, can be #GST_STATE_VOID_PENDING if
518  * the element is in the correct state.
519  * @pending_state: the final state the element should go to, can be
520  * #GST_STATE_VOID_PENDING if the element is in the correct state
521  * @last_return: the last return value of an element state change
522  * @bus: the bus of the element. This bus is provided to the element by the
523  * parent element or the application. A #GstPipeline has a bus of its own.
524  * @clock: the clock of the element. This clock is usually provided to the
525  * element by the toplevel #GstPipeline.
526  * @base_time: the time of the clock right before the element is set to
527  * PLAYING. Subtracting @base_time from the current clock time in the PLAYING
528  * state will yield the running_time against the clock.
529  * @numpads: number of pads of the element, includes both source and sink pads.
530  * @pads: list of pads
531  * @numsrcpads: number of source pads of the element.
532  * @srcpads: list of source pads
533  * @numsinkpads: number of sink pads of the element.
534  * @sinkpads: list of sink pads
535  * @pads_cookie: updated whenever the a pad is added or removed
536  *
537  * GStreamer element abstract base class.
538  */
539 struct _GstElement
541   GstObject             object;
543   /*< public >*/ /* with LOCK */
544   GStaticRecMutex      *state_lock;
546   /* element state */
547   GCond                *state_cond;
548   guint32               state_cookie;
549   GstState              current_state;
550   GstState              next_state;
551   GstState              pending_state;
552   GstStateChangeReturn  last_return;
554   GstBus               *bus;
556   /* allocated clock */
557   GstClock             *clock;
558   GstClockTimeDiff      base_time; /* NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock */
560   /* element pads, these lists can only be iterated while holding
561    * the LOCK or checking the cookie after each LOCK. */
562   guint16               numpads;
563   GList                *pads;
564   guint16               numsrcpads;
565   GList                *srcpads;
566   guint16               numsinkpads;
567   GList                *sinkpads;
568   guint32               pads_cookie;
570   /*< private >*/
571   union {
572     struct {
573       /* state set by application */
574       GstState              target_state;
575       /* running time of the last PAUSED state */
576       GstClockTime          start_time;
577     } ABI;
578     /* adding + 0 to mark ABI change to be undone later */
579     gpointer _gst_reserved[GST_PADDING + 0];
580   } abidata;
581 };
583 /**
584  * GstElementClass:
585  * @parent_class: the parent class structure
586  * @details: #GstElementDetails for elements of this class
587  * @elementfactory: the #GstElementFactory that creates these elements
588  * @padtemplates: a #GList of #GstPadTemplate
589  * @numpadtemplates: the number of padtemplates
590  * @pad_templ_cookie: changed whenever the padtemplates change
591  * @request_new_pad: called when a new pad is requested
592  * @release_pad: called when a request pad is to be released
593  * @get_state: get the state of the element
594  * @set_state: set a new state on the element
595  * @change_state: called by @set_state to perform an incremental state change
596  * @set_bus: set a #GstBus on the element
597  * @provide_clock: gets the #GstClock provided by the element
598  * @set_clock: set the #GstClock on the element
599  * @get_index: set a #GstIndex on the element
600  * @set_index: get the #GstIndex of an element
601  * @send_event: send a #GstEvent to the element
602  * @get_query_types: get the supported #GstQueryType of this element
603  * @query: perform a #GstQuery on the element
604  *
605  * GStreamer element class. Override the vmethods to implement the element
606  * functionality.
607  */
608 struct _GstElementClass
610   GstObjectClass         parent_class;
612   /*< public >*/
613   /* the element details */
614   /* FIXME-0.11: deprecate this in favour of meta_data */
615   GstElementDetails      details;
617   /* factory that the element was created from */
618   GstElementFactory     *elementfactory;
620   /* templates for our pads */
621   GList                 *padtemplates;
622   gint                   numpadtemplates;
623   guint32                pad_templ_cookie;
625   /*< private >*/
626   /* signal callbacks */
627   void (*pad_added)     (GstElement *element, GstPad *pad);
628   void (*pad_removed)   (GstElement *element, GstPad *pad);
629   void (*no_more_pads)  (GstElement *element);
631   /*< public >*/
632   /* virtual methods for subclasses */
634   /* request/release pads */
635   GstPad*               (*request_new_pad)      (GstElement *element, GstPadTemplate *templ, const gchar* name);
636   void                  (*release_pad)          (GstElement *element, GstPad *pad);
638   /* state changes */
639   GstStateChangeReturn (*get_state)             (GstElement * element, GstState * state,
640                                                  GstState * pending, GstClockTime timeout);
641   GstStateChangeReturn (*set_state)             (GstElement *element, GstState state);
642   GstStateChangeReturn (*change_state)          (GstElement *element, GstStateChange transition);
644   /* bus */
645   void                  (*set_bus)              (GstElement * element, GstBus * bus);
647   /* set/get clocks */
648   GstClock*             (*provide_clock)        (GstElement *element);
649   gboolean              (*set_clock)            (GstElement *element, GstClock *clock);
651   /* index */
652   GstIndex*             (*get_index)            (GstElement *element);
653   void                  (*set_index)            (GstElement *element, GstIndex *index);
655   /* query functions */
656   gboolean              (*send_event)           (GstElement *element, GstEvent *event);
658   const GstQueryType*   (*get_query_types)      (GstElement *element);
659   gboolean              (*query)                (GstElement *element, GstQuery *query);
661   /*< private >*/
662   /* FIXME-0.11: move up and replace details */
663   gpointer              meta_data;
665   gpointer _gst_reserved[GST_PADDING-1];
666 };
668 /* element class pad templates */
669 void                    gst_element_class_add_pad_template      (GstElementClass *klass, GstPadTemplate *templ);
670 GstPadTemplate*         gst_element_class_get_pad_template      (GstElementClass *element_class, const gchar *name);
671 GList*                  gst_element_class_get_pad_template_list (GstElementClass *element_class);
673 /* element class meta data */
674 void                    gst_element_class_set_documentation_uri (GstElementClass * klass, const gchar *uri);
675 void                    gst_element_class_set_icon_name         (GstElementClass * klass, const gchar *name);
676 #ifndef GST_DISABLE_DEPRECATED
677 void                    gst_element_class_set_details           (GstElementClass *klass, const GstElementDetails *details);
678 #endif
679 void                    gst_element_class_set_details_simple    (GstElementClass *klass,
680                                                                  const gchar     *longname,
681                                                                  const gchar     *classification,
682                                                                  const gchar     *description,
683                                                                  const gchar     *author);
685 /* element instance */
686 GType                   gst_element_get_type            (void);
688 /* basic name and parentage stuff from GstObject */
690 /**
691  * gst_element_get_name:
692  * @elem: a #GstElement to get the name of @elem.
693  *
694  * Returns a copy of the name of @elem.
695  * Caller should g_free() the return value after usage.
696  * For a nameless element, this returns NULL, which you can safely g_free()
697  * as well.
698  *
699  * Returns: (transfer full): the name of @elem. g_free() after usage. MT safe.
700  *
701  */
702 #define                 gst_element_get_name(elem)      gst_object_get_name(GST_OBJECT_CAST(elem))
704 /**
705  * gst_element_set_name:
706  * @elem: a #GstElement to set the name of.
707  * @name: the new name
708  *
709  * Sets the name of the element, getting rid of the old name if there was one.
710  */
711 #define                 gst_element_set_name(elem,name) gst_object_set_name(GST_OBJECT_CAST(elem),name)
713 /**
714  * gst_element_get_parent:
715  * @elem: a #GstElement to get the parent of.
716  *
717  * Returns: (transfer full): the parent of an element.
718  */
719 #define                 gst_element_get_parent(elem)    gst_object_get_parent(GST_OBJECT_CAST(elem))
721 /**
722  * gst_element_set_parent:
723  * @elem: a #GstElement to set the parent of.
724  * @parent: the new parent #GstObject of the element.
725  *
726  * Sets the parent of an element.
727  */
728 #define                 gst_element_set_parent(elem,parent)     gst_object_set_parent(GST_OBJECT_CAST(elem),parent)
730 /* clocking */
731 gboolean                gst_element_requires_clock      (GstElement *element);
732 gboolean                gst_element_provides_clock      (GstElement *element);
733 GstClock*               gst_element_provide_clock       (GstElement *element);
734 GstClock*               gst_element_get_clock           (GstElement *element);
735 gboolean                gst_element_set_clock           (GstElement *element, GstClock *clock);
736 void                    gst_element_set_base_time       (GstElement *element, GstClockTime time);
737 GstClockTime            gst_element_get_base_time       (GstElement *element);
738 void                    gst_element_set_start_time      (GstElement *element, GstClockTime time);
739 GstClockTime            gst_element_get_start_time      (GstElement *element);
741 /* indexes */
742 gboolean                gst_element_is_indexable        (GstElement *element);
743 void                    gst_element_set_index           (GstElement *element, GstIndex *index);
744 GstIndex*               gst_element_get_index           (GstElement *element);
746 /* bus */
747 void                    gst_element_set_bus             (GstElement * element, GstBus * bus);
748 GstBus *                gst_element_get_bus             (GstElement * element);
750 /* pad management */
751 gboolean                gst_element_add_pad             (GstElement *element, GstPad *pad);
752 gboolean                gst_element_remove_pad          (GstElement *element, GstPad *pad);
753 void                    gst_element_no_more_pads        (GstElement *element);
755 #ifndef GST_DISABLE_DEPRECATED
756 GstPad*                 gst_element_get_pad             (GstElement *element, const gchar *name);
757 #endif /* GST_DISABLE_DEPRECATED */
758 GstPad*                 gst_element_get_static_pad      (GstElement *element, const gchar *name);
759 GstPad*                 gst_element_get_request_pad     (GstElement *element, const gchar *name);
760 void                    gst_element_release_request_pad (GstElement *element, GstPad *pad);
762 GstIterator *           gst_element_iterate_pads        (GstElement * element);
763 GstIterator *           gst_element_iterate_src_pads    (GstElement * element);
764 GstIterator *           gst_element_iterate_sink_pads   (GstElement * element);
766 /* event/query/format stuff */
767 gboolean                gst_element_send_event          (GstElement *element, GstEvent *event);
768 gboolean                gst_element_seek                (GstElement *element, gdouble rate,
769                                                          GstFormat format, GstSeekFlags flags,
770                                                          GstSeekType cur_type, gint64 cur,
771                                                          GstSeekType stop_type, gint64 stop);
772 G_CONST_RETURN GstQueryType*
773                         gst_element_get_query_types     (GstElement *element);
774 gboolean                gst_element_query               (GstElement *element, GstQuery *query);
776 /* messages */
777 gboolean                gst_element_post_message        (GstElement * element, GstMessage * message);
779 /* error handling */
780 /* gcc versions < 3.3 warn about NULL being passed as format to printf */
781 #if (defined(GST_USING_PRINTF_EXTENSION) || !defined(__GNUC__) || (__GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 3))
782 gchar *                 _gst_element_error_printf       (const gchar *format, ...);
783 #else
784 gchar *                 _gst_element_error_printf       (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
785 #endif
786 void                    gst_element_message_full        (GstElement * element, GstMessageType type,
787                                                          GQuark domain, gint code, gchar * text,
788                                                          gchar * debug, const gchar * file,
789                                                          const gchar * function, gint line);
791 /* state management */
792 gboolean                gst_element_is_locked_state     (GstElement *element);
793 gboolean                gst_element_set_locked_state    (GstElement *element, gboolean locked_state);
794 gboolean                gst_element_sync_state_with_parent (GstElement *element);
796 GstStateChangeReturn    gst_element_get_state           (GstElement * element,
797                                                          GstState * state,
798                                                          GstState * pending,
799                                                          GstClockTime timeout);
800 GstStateChangeReturn    gst_element_set_state           (GstElement *element, GstState state);
802 void                    gst_element_abort_state         (GstElement * element);
803 GstStateChangeReturn    gst_element_change_state        (GstElement * element,
804                                                          GstStateChange transition);
805 GstStateChangeReturn    gst_element_continue_state      (GstElement * element,
806                                                          GstStateChangeReturn ret);
807 void                    gst_element_lost_state          (GstElement * element);
808 void                    gst_element_lost_state_full     (GstElement * element, gboolean new_base_time);
810 /* factory management */
811 GstElementFactory*      gst_element_get_factory         (GstElement *element);
813 G_END_DECLS
815 #endif /* __GST_ELEMENT_H__ */