docs: expose GstPushSrcClass in documentation
[platform/upstream/gstreamer.git] / gst / gstpad.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wim.taymans@chello.be>
4  *
5  * gstpad.h: Header for GstPad object
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., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23
24 #ifndef __GST_PAD_H__
25 #define __GST_PAD_H__
26
27 #include <gst/gstconfig.h>
28
29 typedef struct _GstPad GstPad;
30 typedef struct _GstPadPrivate GstPadPrivate;
31 typedef struct _GstPadClass GstPadClass;
32 typedef struct _GstPadProbeInfo GstPadProbeInfo;
33
34 /**
35  * GstPadDirection:
36  * @GST_PAD_UNKNOWN: direction is unknown.
37  * @GST_PAD_SRC: the pad is a source pad.
38  * @GST_PAD_SINK: the pad is a sink pad.
39  *
40  * The direction of a pad.
41  */
42 typedef enum {
43   GST_PAD_UNKNOWN,
44   GST_PAD_SRC,
45   GST_PAD_SINK
46 } GstPadDirection;
47
48 /**
49  * GstPadMode:
50  * @GST_PAD_MODE_NONE: Pad will not handle dataflow
51  * @GST_PAD_MODE_PUSH: Pad handles dataflow in downstream push mode
52  * @GST_PAD_MODE_PULL: Pad handles dataflow in upstream pull mode
53  *
54  * The status of a GstPad. After activating a pad, which usually happens when the
55  * parent element goes from READY to PAUSED, the GstPadMode defines if the
56  * pad operates in push or pull mode.
57  */
58 typedef enum {
59   GST_PAD_MODE_NONE,
60   GST_PAD_MODE_PUSH,
61   GST_PAD_MODE_PULL
62 } GstPadMode;
63
64 const gchar   * gst_pad_mode_get_name (GstPadMode mode);
65
66 #include <gst/gstobject.h>
67 #include <gst/gstbuffer.h>
68 #include <gst/gstbufferlist.h>
69 #include <gst/gstcaps.h>
70 #include <gst/gstpadtemplate.h>
71 #include <gst/gstevent.h>
72 #include <gst/gstquery.h>
73 #include <gst/gsttask.h>
74
75 G_BEGIN_DECLS
76
77 /*
78  * Pad base class
79  */
80 #define GST_TYPE_PAD                    (gst_pad_get_type ())
81 #define GST_IS_PAD(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD))
82 #define GST_IS_PAD_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD))
83 #define GST_PAD(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad))
84 #define GST_PAD_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass))
85 #define GST_PAD_CAST(obj)               ((GstPad*)(obj))
86
87
88
89 /**
90  * GstPadLinkReturn:
91  * @GST_PAD_LINK_OK             : link succeeded
92  * @GST_PAD_LINK_WRONG_HIERARCHY: pads have no common grandparent
93  * @GST_PAD_LINK_WAS_LINKED     : pad was already linked
94  * @GST_PAD_LINK_WRONG_DIRECTION: pads have wrong direction
95  * @GST_PAD_LINK_NOFORMAT       : pads do not have common format
96  * @GST_PAD_LINK_NOSCHED        : pads cannot cooperate in scheduling
97  * @GST_PAD_LINK_REFUSED        : refused for some reason
98  *
99  * Result values from gst_pad_link and friends.
100  */
101 typedef enum {
102   GST_PAD_LINK_OK               =  0,
103   GST_PAD_LINK_WRONG_HIERARCHY  = -1,
104   GST_PAD_LINK_WAS_LINKED       = -2,
105   GST_PAD_LINK_WRONG_DIRECTION  = -3,
106   GST_PAD_LINK_NOFORMAT         = -4,
107   GST_PAD_LINK_NOSCHED          = -5,
108   GST_PAD_LINK_REFUSED          = -6
109 } GstPadLinkReturn;
110
111 /**
112  * GST_PAD_LINK_FAILED:
113  * @ret: the #GstPadLinkReturn value
114  *
115  * Macro to test if the given #GstPadLinkReturn value indicates a failed
116  * link step.
117  */
118 #define GST_PAD_LINK_FAILED(ret) ((ret) < GST_PAD_LINK_OK)
119
120 /**
121  * GST_PAD_LINK_SUCCESSFUL:
122  * @ret: the #GstPadLinkReturn value
123  *
124  * Macro to test if the given #GstPadLinkReturn value indicates a successful
125  * link step.
126  */
127 #define GST_PAD_LINK_SUCCESSFUL(ret) ((ret) >= GST_PAD_LINK_OK)
128
129 /**
130  * GstFlowReturn:
131  * @GST_FLOW_OK:                 Data passing was ok.
132  * @GST_FLOW_NOT_LINKED:         Pad is not linked.
133  * @GST_FLOW_FLUSHING:           Pad is flushing.
134  * @GST_FLOW_EOS:                Pad is EOS.
135  * @GST_FLOW_NOT_NEGOTIATED:     Pad is not negotiated.
136  * @GST_FLOW_ERROR:              Some (fatal) error occurred. Element generating
137  *                               this error should post an error message with more
138  *                               details.
139  * @GST_FLOW_NOT_SUPPORTED:      This operation is not supported.
140  * @GST_FLOW_CUSTOM_SUCCESS:     Elements can use values starting from
141  *                               this (and higher) to define custom success
142  *                               codes.
143  * @GST_FLOW_CUSTOM_SUCCESS_1:   Pre-defined custom success code (define your
144  *                               custom success code to this to avoid compiler
145  *                               warnings).
146  * @GST_FLOW_CUSTOM_SUCCESS_2:   Pre-defined custom success code.
147  * @GST_FLOW_CUSTOM_ERROR:       Elements can use values starting from
148  *                               this (and lower) to define custom error codes.
149  * @GST_FLOW_CUSTOM_ERROR_1:     Pre-defined custom error code (define your
150  *                               custom error code to this to avoid compiler
151  *                               warnings).
152  * @GST_FLOW_CUSTOM_ERROR_2:     Pre-defined custom error code.
153  *
154  * The result of passing data to a pad.
155  *
156  * Note that the custom return values should not be exposed outside of the
157  * element scope.
158  */
159 typedef enum {
160   /* custom success starts here */
161   GST_FLOW_CUSTOM_SUCCESS_2 = 102,
162   GST_FLOW_CUSTOM_SUCCESS_1 = 101,
163   GST_FLOW_CUSTOM_SUCCESS = 100,
164
165   /* core predefined */
166   GST_FLOW_OK             =  0,
167   /* expected failures */
168   GST_FLOW_NOT_LINKED     = -1,
169   GST_FLOW_FLUSHING       = -2,
170   /* error cases */
171   GST_FLOW_EOS            = -3,
172   GST_FLOW_NOT_NEGOTIATED = -4,
173   GST_FLOW_ERROR          = -5,
174   GST_FLOW_NOT_SUPPORTED  = -6,
175
176   /* custom error starts here */
177   GST_FLOW_CUSTOM_ERROR   = -100,
178   GST_FLOW_CUSTOM_ERROR_1 = -101,
179   GST_FLOW_CUSTOM_ERROR_2 = -102
180 } GstFlowReturn;
181
182 const gchar*            gst_flow_get_name (GstFlowReturn ret);
183 GQuark                            gst_flow_to_quark (GstFlowReturn ret);
184 const gchar*          gst_pad_link_get_name (GstPadLinkReturn ret);
185
186 /**
187  * GstPadLinkCheck:
188  * @GST_PAD_LINK_CHECK_NOTHING: Don't check hierarchy or caps compatibility.
189  * @GST_PAD_LINK_CHECK_HIERARCHY: Check the pads have same parents/grandparents.
190  *   Could be omitted if it is already known that the two elements that own the
191  *   pads are in the same bin.
192  * @GST_PAD_LINK_CHECK_TEMPLATE_CAPS: Check if the pads are compatible by using
193  *   their template caps. This is much faster than @GST_PAD_LINK_CHECK_CAPS, but
194  *   would be unsafe e.g. if one pad has %GST_CAPS_ANY.
195  * @GST_PAD_LINK_CHECK_CAPS: Check if the pads are compatible by comparing the
196  *   caps returned by gst_pad_query_caps().
197  * @GST_PAD_LINK_CHECK_DEFAULT: The default checks done when linking
198  *   pads (i.e. the ones used by gst_pad_link()).
199  *
200  * The amount of checking to be done when linking pads. @GST_PAD_LINK_CHECK_CAPS
201  * and @GST_PAD_LINK_CHECK_TEMPLATE_CAPS are mutually exclusive. If both are
202  * specified, expensive but safe @GST_PAD_LINK_CHECK_CAPS are performed.
203  *
204  * <warning><para>
205  * Only disable some of the checks if you are 100% certain you know the link
206  * will not fail because of hierarchy/caps compatibility failures. If uncertain,
207  * use the default checks (%GST_PAD_LINK_CHECK_DEFAULT) or the regular methods
208  * for linking the pads.
209  * </para></warning>
210  */
211
212 typedef enum {
213   GST_PAD_LINK_CHECK_NOTHING       = 0,
214   GST_PAD_LINK_CHECK_HIERARCHY     = 1 << 0,
215   GST_PAD_LINK_CHECK_TEMPLATE_CAPS = 1 << 1,
216   GST_PAD_LINK_CHECK_CAPS          = 1 << 2,
217
218   GST_PAD_LINK_CHECK_DEFAULT       = GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_CAPS
219 } GstPadLinkCheck;
220
221 /* pad states */
222 /**
223  * GstPadActivateFunction:
224  * @pad: a #GstPad
225  * @parent: the parent of @pad
226  *
227  * This function is called when the pad is activated during the element
228  * READY to PAUSED state change. By default this function will call the
229  * activate function that puts the pad in push mode but elements can
230  * override this function to activate the pad in pull mode if they wish.
231  *
232  * Returns: TRUE if the pad could be activated.
233  */
234 typedef gboolean                (*GstPadActivateFunction)       (GstPad *pad, GstObject *parent);
235 /**
236  * GstPadActivateModeFunction:
237  * @pad: a #GstPad
238  * @parent: the parent of @pad
239  * @mode: the requested activation mode of @pad
240  * @active: activate or deactivate the pad.
241  *
242  * The prototype of the push and pull activate functions.
243  *
244  * Returns: TRUE if the pad could be activated or deactivated.
245  */
246 typedef gboolean                (*GstPadActivateModeFunction)   (GstPad *pad, GstObject *parent,
247                                                                  GstPadMode mode, gboolean active);
248
249
250 /* data passing */
251 /**
252  * GstPadChainFunction:
253  * @pad: the sink #GstPad that performed the chain.
254  * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
255  *          @parent is guaranteed to be not-NULL and remain valid during the
256  *          execution of this function.
257  * @buffer: the #GstBuffer that is chained, not %NULL.
258  *
259  * A function that will be called on sinkpads when chaining buffers.
260  * The function typically processes the data contained in the buffer and
261  * either consumes the data or passes it on to the internally linked pad(s).
262  *
263  * The implementer of this function receives a refcount to @buffer and should
264  * gst_buffer_unref() when the buffer is no longer needed.
265  *
266  * When a chain function detects an error in the data stream, it must post an
267  * error on the bus and return an appropriate #GstFlowReturn value.
268  *
269  * Returns: #GST_FLOW_OK for success
270  */
271 typedef GstFlowReturn           (*GstPadChainFunction)          (GstPad *pad, GstObject *parent,
272                                                                  GstBuffer *buffer);
273
274 /**
275  * GstPadChainListFunction:
276  * @pad: the sink #GstPad that performed the chain.
277  * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
278  *          @parent is guaranteed to be not-NULL and remain valid during the
279  *          execution of this function.
280  * @list: the #GstBufferList that is chained, not %NULL.
281  *
282  * A function that will be called on sinkpads when chaining buffer lists.
283  * The function typically processes the data contained in the buffer list and
284  * either consumes the data or passes it on to the internally linked pad(s).
285  *
286  * The implementer of this function receives a refcount to @list and
287  * should gst_buffer_list_unref() when the list is no longer needed.
288  *
289  * When a chainlist function detects an error in the data stream, it must
290  * post an error on the bus and return an appropriate #GstFlowReturn value.
291  *
292  * Returns: #GST_FLOW_OK for success
293  */
294 typedef GstFlowReturn           (*GstPadChainListFunction)      (GstPad *pad, GstObject *parent,
295                                                                  GstBufferList *list);
296
297 /**
298  * GstPadGetRangeFunction:
299  * @pad: the src #GstPad to perform the getrange on.
300  * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
301  *          @parent is guaranteed to be not-NULL and remain valid during the
302  *          execution of this function.
303  * @offset: the offset of the range
304  * @length: the length of the range
305  * @buffer: a memory location to hold the result buffer, cannot be NULL.
306  *
307  * This function will be called on source pads when a peer element
308  * request a buffer at the specified @offset and @length. If this function
309  * returns #GST_FLOW_OK, the result buffer will be stored in @buffer. The
310  * contents of @buffer is invalid for any other return value.
311  *
312  * This function is installed on a source pad with
313  * gst_pad_set_getrange_function() and can only be called on source pads after
314  * they are successfully activated with gst_pad_activate_mode() with the
315  * #GST_PAD_MODE_PULL.
316  *
317  * @offset and @length are always given in byte units. @offset must normally be a value
318  * between 0 and the length in bytes of the data available on @pad. The
319  * length (duration in bytes) can be retrieved with a #GST_QUERY_DURATION or with a
320  * #GST_QUERY_SEEKING.
321  *
322  * Any @offset larger or equal than the length will make the function return
323  * #GST_FLOW_EOS, which corresponds to EOS. In this case @buffer does not
324  * contain a valid buffer.
325  *
326  * The buffer size of @buffer will only be smaller than @length when @offset is
327  * near the end of the stream. In all other cases, the size of @buffer must be
328  * exactly the requested size.
329  *
330  * It is allowed to call this function with a 0 @length and valid @offset, in
331  * which case @buffer will contain a 0-sized buffer and the function returns
332  * #GST_FLOW_OK.
333  *
334  * When this function is called with a -1 @offset, the sequentially next buffer
335  * of length @length in the stream is returned.
336  *
337  * When this function is called with a -1 @length, a buffer with a default
338  * optimal length is returned in @buffer. The length might depend on the value
339  * of @offset.
340  *
341  * Returns: #GST_FLOW_OK for success and a valid buffer in @buffer. Any other
342  * return value leaves @buffer undefined.
343  */
344 typedef GstFlowReturn           (*GstPadGetRangeFunction)       (GstPad *pad, GstObject *parent,
345                                                                  guint64 offset, guint length,
346                                                                  GstBuffer **buffer);
347
348 /**
349  * GstPadEventFunction:
350  * @pad: the #GstPad to handle the event.
351  * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
352  *          @parent is guaranteed to be not-NULL and remain valid during the
353  *          execution of this function.
354  * @event: the #GstEvent to handle.
355  *
356  * Function signature to handle an event for the pad.
357  *
358  * Returns: TRUE if the pad could handle the event.
359  */
360 typedef gboolean                (*GstPadEventFunction)          (GstPad *pad, GstObject *parent,
361                                                                  GstEvent *event);
362
363
364 /* internal links */
365 /**
366  * GstPadIterIntLinkFunction:
367  * @pad: The #GstPad to query.
368  * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
369  *          @parent is guaranteed to be not-NULL and remain valid during the
370  *          execution of this function.
371  *
372  * The signature of the internal pad link iterator function.
373  *
374  * Returns: a new #GstIterator that will iterate over all pads that are
375  * linked to the given pad on the inside of the parent element.
376  *
377  * the caller must call gst_iterator_free() after usage.
378  */
379 typedef GstIterator*           (*GstPadIterIntLinkFunction)    (GstPad *pad, GstObject *parent);
380
381 /* generic query function */
382 /**
383  * GstPadQueryFunction:
384  * @pad: the #GstPad to query.
385  * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
386  *          @parent is guaranteed to be not-NULL and remain valid during the
387  *          execution of this function.
388  * @query: the #GstQuery object to execute
389  *
390  * The signature of the query function.
391  *
392  * Returns: TRUE if the query could be performed.
393  */
394 typedef gboolean                (*GstPadQueryFunction)          (GstPad *pad, GstObject *parent,
395                                                                  GstQuery *query);
396
397
398 /* linking */
399 /**
400  * GstPadLinkFunction:
401  * @pad: the #GstPad that is linked.
402  * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
403  *          @parent is guaranteed to be not-NULL and remain valid during the
404  *          execution of this function.
405  * @peer: the peer #GstPad of the link
406  *
407  * Function signature to handle a new link on the pad.
408  *
409  * Returns: the result of the link with the specified peer.
410  */
411 typedef GstPadLinkReturn        (*GstPadLinkFunction)           (GstPad *pad, GstObject *parent, GstPad *peer);
412 /**
413  * GstPadUnlinkFunction:
414  * @pad: the #GstPad that is linked.
415  * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
416  *          @parent is guaranteed to be not-NULL and remain valid during the
417  *          execution of this function.
418  *
419  * Function signature to handle a unlinking the pad prom its peer.
420  */
421 typedef void                    (*GstPadUnlinkFunction)         (GstPad *pad, GstObject *parent);
422
423
424 /* misc */
425 /**
426  * GstPadForwardFunction:
427  * @pad: the #GstPad that is forwarded.
428  * @user_data: the gpointer to optional user data.
429  *
430  * A forward function is called for all internally linked pads, see
431  * gst_pad_forward().
432  *
433  * Returns: TRUE if the dispatching procedure has to be stopped.
434  */
435 typedef gboolean                (*GstPadForwardFunction)        (GstPad *pad, gpointer user_data);
436
437 /**
438  * GstPadProbeType:
439  * @GST_PAD_PROBE_TYPE_INVALID: invalid probe type
440  * @GST_PAD_PROBE_TYPE_IDLE: probe idle pads and block
441  * @GST_PAD_PROBE_TYPE_BLOCK: probe and block pads
442  * @GST_PAD_PROBE_TYPE_BUFFER: probe buffers
443  * @GST_PAD_PROBE_TYPE_BUFFER_LIST: probe buffer lists
444  * @GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM: probe downstream events
445  * @GST_PAD_PROBE_TYPE_EVENT_UPSTREAM: probe upstream events
446  * @GST_PAD_PROBE_TYPE_EVENT_FLUSH: probe flush events. This probe has to be
447  *     explicitly enabled and is not included in the
448  *     @@GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM or
449  *     @@GST_PAD_PROBE_TYPE_EVENT_UPSTREAM probe types.
450  * @GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM: probe downstream queries
451  * @GST_PAD_PROBE_TYPE_QUERY_UPSTREAM: probe upstream queries
452  * @GST_PAD_PROBE_TYPE_PUSH: probe push
453  * @GST_PAD_PROBE_TYPE_PULL: probe pull
454  * @GST_PAD_PROBE_TYPE_BLOCKING: probe and block at the next opportunity, at data flow or when idle
455  * @GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM: probe downstream data (buffers, buffer lists, and events)
456  * @GST_PAD_PROBE_TYPE_DATA_UPSTREAM: probe upstream data (events)
457  * @GST_PAD_PROBE_TYPE_DATA_BOTH: probe upstream and downstream data (buffers, buffer lists, and events)
458  * @GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM: probe and block downstream data (buffers, buffer lists, and events)
459  * @GST_PAD_PROBE_TYPE_BLOCK_UPSTREAM: probe and block upstream data (events)
460  * @GST_PAD_PROBE_TYPE_EVENT_BOTH: probe upstream and downstream events
461  * @GST_PAD_PROBE_TYPE_QUERY_BOTH: probe upstream and downstream queries
462  * @GST_PAD_PROBE_TYPE_ALL_BOTH: probe upstream events and queries and downstream buffers, buffer lists, events and queries
463  * @GST_PAD_PROBE_TYPE_SCHEDULING: probe push and pull
464  *
465  * The different probing types that can occur. When either one of
466  * @GST_PAD_PROBE_TYPE_IDLE or @GST_PAD_PROBE_TYPE_BLOCK is used, the probe will be a
467  * blocking probe.
468  */
469 typedef enum
470 {
471   GST_PAD_PROBE_TYPE_INVALID          = 0,
472   /* flags to control blocking */
473   GST_PAD_PROBE_TYPE_IDLE             = (1 << 0),
474   GST_PAD_PROBE_TYPE_BLOCK            = (1 << 1),
475   /* flags to select datatypes */
476   GST_PAD_PROBE_TYPE_BUFFER           = (1 << 4),
477   GST_PAD_PROBE_TYPE_BUFFER_LIST      = (1 << 5),
478   GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM = (1 << 6),
479   GST_PAD_PROBE_TYPE_EVENT_UPSTREAM   = (1 << 7),
480   GST_PAD_PROBE_TYPE_EVENT_FLUSH      = (1 << 8),
481   GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM = (1 << 9),
482   GST_PAD_PROBE_TYPE_QUERY_UPSTREAM   = (1 << 10),
483   /* flags to select scheduling mode */
484   GST_PAD_PROBE_TYPE_PUSH             = (1 << 12),
485   GST_PAD_PROBE_TYPE_PULL             = (1 << 13),
486
487   /* flag combinations */
488   GST_PAD_PROBE_TYPE_BLOCKING         = GST_PAD_PROBE_TYPE_IDLE | GST_PAD_PROBE_TYPE_BLOCK,
489   GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM  = GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
490   GST_PAD_PROBE_TYPE_DATA_UPSTREAM    = GST_PAD_PROBE_TYPE_EVENT_UPSTREAM,
491   GST_PAD_PROBE_TYPE_DATA_BOTH        = GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM | GST_PAD_PROBE_TYPE_DATA_UPSTREAM,
492   GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM = GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM,
493   GST_PAD_PROBE_TYPE_BLOCK_UPSTREAM   = GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_UPSTREAM,
494   GST_PAD_PROBE_TYPE_EVENT_BOTH       = GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM | GST_PAD_PROBE_TYPE_EVENT_UPSTREAM,
495   GST_PAD_PROBE_TYPE_QUERY_BOTH       = GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM | GST_PAD_PROBE_TYPE_QUERY_UPSTREAM,
496   GST_PAD_PROBE_TYPE_ALL_BOTH         = GST_PAD_PROBE_TYPE_DATA_BOTH | GST_PAD_PROBE_TYPE_QUERY_BOTH,
497   GST_PAD_PROBE_TYPE_SCHEDULING       = GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_PULL
498 } GstPadProbeType;
499
500
501 /**
502  * GstPadProbeReturn:
503  * @GST_PAD_PROBE_OK: normal probe return value
504  * @GST_PAD_PROBE_DROP: drop data in data probes. For push mode this means that
505  *        the data item is not sent downstream. For pull mode, it means that the
506  *        data item is not passed upstream. In both cases, this result code
507  *        means that #GST_FLOW_OK or %TRUE is returned to the caller.
508  * @GST_PAD_PROBE_REMOVE: remove probe
509  * @GST_PAD_PROBE_PASS: pass the data item in the block probe and block on
510  *                         the next item
511  *
512  * Different return values for the #GstPadProbeCallback.
513  */
514 typedef enum
515 {
516   GST_PAD_PROBE_DROP,
517   GST_PAD_PROBE_OK,
518   GST_PAD_PROBE_REMOVE,
519   GST_PAD_PROBE_PASS,
520 } GstPadProbeReturn;
521
522
523 /**
524  * GstPadProbeInfo:
525  * @type: the current probe type
526  * @id: the id of the probe
527  * @data: type specific data, check the @type field to know the datatype.
528  *    This field can be NULL.
529  * @offset: offset of pull probe, this field is valid when @type contains
530  *    #GST_PAD_PROBE_TYPE_PULL
531  * @size: size of pull probe, this field is valid when @type contains
532  *    #GST_PAD_PROBE_TYPE_PULL
533  *
534  * Info passed in the #GstPadProbeCallback.
535  */
536 struct _GstPadProbeInfo
537 {
538   GstPadProbeType type;
539   gulong id;
540   gpointer data;
541   guint64 offset;
542   guint size;
543
544   /*< private >*/
545   gpointer _gst_reserved[GST_PADDING];
546 };
547
548 #define GST_PAD_PROBE_INFO_TYPE(d)         ((d)->type)
549 #define GST_PAD_PROBE_INFO_ID(d)           ((d)->id)
550 #define GST_PAD_PROBE_INFO_DATA(d)         ((d)->data)
551
552 #define GST_PAD_PROBE_INFO_BUFFER(d)       GST_BUFFER_CAST(GST_PAD_PROBE_INFO_DATA(d))
553 #define GST_PAD_PROBE_INFO_BUFFER_LIST(d)  GST_BUFFER_LIST_CAST(GST_PAD_PROBE_INFO_DATA(d))
554 #define GST_PAD_PROBE_INFO_EVENT(d)        GST_EVENT_CAST(GST_PAD_PROBE_INFO_DATA(d))
555 #define GST_PAD_PROBE_INFO_QUERY(d)        GST_QUERY_CAST(GST_PAD_PROBE_INFO_DATA(d))
556
557 #define GST_PAD_PROBE_INFO_OFFSET(d)       ((d)->offset)
558 #define GST_PAD_PROBE_INFO_SIZE(d)         ((d)->size)
559
560 GstEvent*      gst_pad_probe_info_get_event       (GstPadProbeInfo * info);
561 GstQuery*      gst_pad_probe_info_get_query       (GstPadProbeInfo * info);
562 GstBuffer*     gst_pad_probe_info_get_buffer      (GstPadProbeInfo * info);
563 GstBufferList* gst_pad_probe_info_get_buffer_list (GstPadProbeInfo * info);
564
565 /**
566  * GstPadProbeCallback:
567  * @pad: the #GstPad that is blocked
568  * @info: #GstPadProbeInfo
569  * @user_data: the gpointer to optional user data.
570  *
571  * Callback used by gst_pad_add_probe(). Gets called to notify about the current
572  * blocking type.
573  *
574  * The callback is allowed to modify the data pointer in @info.
575  *
576  * Returns: a #GstPadProbeReturn
577  */
578 typedef GstPadProbeReturn   (*GstPadProbeCallback)   (GstPad *pad, GstPadProbeInfo *info,
579                                                       gpointer user_data);
580
581 /**
582  * GstPadStickyEventsForeachFunction:
583  * @pad: the #GstPad.
584  * @event: a sticky #GstEvent.
585  * @user_data: the #gpointer to optional user data.
586  *
587  * Callback used by gst_pad_sticky_events_foreach().
588  *
589  * When this function returns %TRUE, the next event will be
590  * returned. When %FALSE is returned, gst_pad_sticky_events_foreach() will return.
591  *
592  * When @event is set to NULL, the item will be removed from the list of sticky events.
593  * @event can be replaced by assigning a new reference to it.
594  * This function is responsible for unreffing the old event when
595  * removing or modifying.
596  *
597  * Returns: %TRUE if the iteration should continue
598  */
599 typedef gboolean  (*GstPadStickyEventsForeachFunction) (GstPad *pad, GstEvent **event,
600                                                         gpointer user_data);
601
602 /**
603  * GstPadFlags:
604  * @GST_PAD_FLAG_BLOCKED: is dataflow on a pad blocked
605  * @GST_PAD_FLAG_FLUSHING: is pad flushing
606  * @GST_PAD_FLAG_EOS: is pad in EOS state
607  * @GST_PAD_FLAG_BLOCKING: is pad currently blocking on a buffer or event
608  * @GST_PAD_FLAG_NEED_PARENT: ensure that there is a parent object before calling
609  *                       into the pad callbacks.
610  * @GST_PAD_FLAG_NEED_RECONFIGURE: the pad should be reconfigured/renegotiated.
611  *                            The flag has to be unset manually after
612  *                            reconfiguration happened.
613  * @GST_PAD_FLAG_PENDING_EVENTS: the pad has pending events
614  * @GST_PAD_FLAG_FIXED_CAPS: the pad is using fixed caps. This means that
615  *     once the caps are set on the pad, the default caps query function
616  *     will only return those caps.
617  * @GST_PAD_FLAG_PROXY_CAPS: the default event and query handler will forward
618  *                      all events and queries to the internally linked pads
619  *                      instead of discarding them.
620  * @GST_PAD_FLAG_PROXY_ALLOCATION: the default query handler will forward
621  *                      allocation queries to the internally linked pads
622  *                      instead of discarding them.
623  * @GST_PAD_FLAG_PROXY_SCHEDULING: the default query handler will forward
624  *                      scheduling queries to the internally linked pads
625  *                      instead of discarding them.
626  * @GST_PAD_FLAG_ACCEPT_INTERSECT: the default accept-caps handler will check
627  *                      it the caps intersect the query-caps result instead
628  *                      of checking for a subset. This is interesting for
629  *                      parsers that can accept incompletely specified caps.
630  * @GST_PAD_FLAG_LAST: offset to define more flags
631  *
632  * Pad state flags
633  */
634 typedef enum {
635   GST_PAD_FLAG_BLOCKED          = (GST_OBJECT_FLAG_LAST << 0),
636   GST_PAD_FLAG_FLUSHING         = (GST_OBJECT_FLAG_LAST << 1),
637   GST_PAD_FLAG_EOS              = (GST_OBJECT_FLAG_LAST << 2),
638   GST_PAD_FLAG_BLOCKING         = (GST_OBJECT_FLAG_LAST << 3),
639   GST_PAD_FLAG_NEED_PARENT      = (GST_OBJECT_FLAG_LAST << 4),
640   GST_PAD_FLAG_NEED_RECONFIGURE = (GST_OBJECT_FLAG_LAST << 5),
641   GST_PAD_FLAG_PENDING_EVENTS   = (GST_OBJECT_FLAG_LAST << 6),
642   GST_PAD_FLAG_FIXED_CAPS       = (GST_OBJECT_FLAG_LAST << 7),
643   GST_PAD_FLAG_PROXY_CAPS       = (GST_OBJECT_FLAG_LAST << 8),
644   GST_PAD_FLAG_PROXY_ALLOCATION = (GST_OBJECT_FLAG_LAST << 9),
645   GST_PAD_FLAG_PROXY_SCHEDULING = (GST_OBJECT_FLAG_LAST << 10),
646   GST_PAD_FLAG_ACCEPT_INTERSECT = (GST_OBJECT_FLAG_LAST << 11),
647   /* padding */
648   GST_PAD_FLAG_LAST        = (GST_OBJECT_FLAG_LAST << 16)
649 } GstPadFlags;
650
651 /**
652  * GstPad:
653  * @element_private: private data owned by the parent element
654  * @padtemplate: padtemplate for this pad
655  * @direction: the direction of the pad, cannot change after creating
656  *             the pad.
657  *
658  * The #GstPad structure. Use the functions to update the variables.
659  */
660 struct _GstPad {
661   GstObject                      object;
662
663   /*< public >*/
664   gpointer                       element_private;
665
666   GstPadTemplate                *padtemplate;
667
668   GstPadDirection                direction;
669
670   /*< private >*/
671   /* streaming rec_lock */
672   GRecMutex                      stream_rec_lock;
673   GstTask                       *task;
674
675   /* block cond, mutex is from the object */
676   GCond                          block_cond;
677   GHookList                      probes;
678
679   GstPadMode                     mode;
680   GstPadActivateFunction         activatefunc;
681   gpointer                       activatedata;
682   GDestroyNotify                 activatenotify;
683   GstPadActivateModeFunction     activatemodefunc;
684   gpointer                       activatemodedata;
685   GDestroyNotify                 activatemodenotify;
686
687   /* pad link */
688   GstPad                        *peer;
689   GstPadLinkFunction             linkfunc;
690   gpointer                       linkdata;
691   GDestroyNotify                 linknotify;
692   GstPadUnlinkFunction           unlinkfunc;
693   gpointer                       unlinkdata;
694   GDestroyNotify                 unlinknotify;
695
696   /* data transport functions */
697   GstPadChainFunction            chainfunc;
698   gpointer                       chaindata;
699   GDestroyNotify                 chainnotify;
700   GstPadChainListFunction        chainlistfunc;
701   gpointer                       chainlistdata;
702   GDestroyNotify                 chainlistnotify;
703   GstPadGetRangeFunction         getrangefunc;
704   gpointer                       getrangedata;
705   GDestroyNotify                 getrangenotify;
706   GstPadEventFunction            eventfunc;
707   gpointer                       eventdata;
708   GDestroyNotify                 eventnotify;
709
710   /* pad offset */
711   gint64                         offset;
712
713   /* generic query method */
714   GstPadQueryFunction            queryfunc;
715   gpointer                       querydata;
716   GDestroyNotify                 querynotify;
717
718   /* internal links */
719   GstPadIterIntLinkFunction      iterintlinkfunc;
720   gpointer                       iterintlinkdata;
721   GDestroyNotify                 iterintlinknotify;
722
723   /* counts number of probes attached. */
724   gint                           num_probes;
725   gint                           num_blocked;
726
727   GstPadPrivate                 *priv;
728
729   gpointer _gst_reserved[GST_PADDING];
730 };
731
732 struct _GstPadClass {
733   GstObjectClass        parent_class;
734
735   /* signal callbacks */
736   void          (*linked)               (GstPad *pad, GstPad *peer);
737   void          (*unlinked)             (GstPad *pad, GstPad *peer);
738
739   /*< private >*/
740   gpointer _gst_reserved[GST_PADDING];
741 };
742
743
744 /***** helper macros *****/
745 /* GstPad */
746
747 /**
748  * GST_PAD_NAME:
749  * @pad: a #GstPad
750  *
751  * Get name of the given pad.
752  * No locking is performed in this function, use gst_pad_get_name() instead.
753  */
754 #define GST_PAD_NAME(pad)               (GST_OBJECT_NAME(pad))
755 /**
756  * GST_PAD_PARENT:
757  * @pad: a #GstPad
758  *
759  * Get the @pad parent.
760  * No locking is performed in this function, use gst_pad_get_parent() instead.
761  */
762 #define GST_PAD_PARENT(pad)             (GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad)))
763 /**
764  * GST_PAD_ELEMENT_PRIVATE:
765  * @pad: a #GstPad
766  *
767  * Get the private data of @pad, which is usually some pad- or stream-specific
768  * structure created by the element and set on the pad when creating it.
769  * No locking is performed in this function.
770  */
771 #define GST_PAD_ELEMENT_PRIVATE(pad)    (GST_PAD_CAST(pad)->element_private)
772 /**
773  * GST_PAD_PAD_TEMPLATE:
774  * @pad: a #GstPad
775  *
776  * Get the @pad #GstPadTemplate. It describes the possible media types
777  * a @pad or an element factory can handle.
778  */
779 #define GST_PAD_PAD_TEMPLATE(pad)       (GST_PAD_CAST(pad)->padtemplate)
780 /**
781  * GST_PAD_DIRECTION:
782  * @pad: a #GstPad
783  *
784  * Get the #GstPadDirection of the given @pad. Accessor macro, use
785  * gst_pad_get_direction() instead.
786  */
787 #define GST_PAD_DIRECTION(pad)          (GST_PAD_CAST(pad)->direction)
788 /**
789  * GST_PAD_TASK:
790  * @pad: a #GstPad
791  *
792  * Get the #GstTask of @pad. Accessor macro used by GStreamer. Use the
793  * gst_pad_start_task(), gst_pad_stop_task() and gst_pad_pause_task()
794  * functions instead.
795  */
796 #define GST_PAD_TASK(pad)               (GST_PAD_CAST(pad)->task)
797 /**
798  * GST_PAD_MODE:
799  * @pad: a #GstPad
800  *
801  * Get the #GstPadMode of pad, which will be GST_PAD_MODE_NONE if the pad
802  * has not been activated yet, and otherwise either GST_PAD_MODE_PUSH or
803  * GST_PAD_MODE_PULL depending on which mode the pad was activated in.
804  */
805 #define GST_PAD_MODE(pad)               (GST_PAD_CAST(pad)->mode)
806 /**
807  * GST_PAD_ACTIVATEFUNC:
808  * @pad: a #GstPad
809  *
810  * Get the #GstPadActivateFunction from @pad.
811  */
812 #define GST_PAD_ACTIVATEFUNC(pad)       (GST_PAD_CAST(pad)->activatefunc)
813 /**
814  * GST_PAD_ACTIVATEMODEFUNC:
815  * @pad: a #GstPad
816  *
817  * Get the #GstPadActivateModeFunction from the given @pad.
818  */
819 #define GST_PAD_ACTIVATEMODEFUNC(pad)   (GST_PAD_CAST(pad)->activatemodefunc)
820 /**
821  * GST_PAD_CHAINFUNC:
822  * @pad: a #GstPad
823  *
824  * Get the #GstPadChainFunction from the given @pad.
825  */
826 #define GST_PAD_CHAINFUNC(pad)          (GST_PAD_CAST(pad)->chainfunc)
827 /**
828  * GST_PAD_CHAINLISTFUNC:
829  * @pad: a #GstPad
830  *
831  * Get the #GstPadChainListFunction from the given @pad.
832  */
833 #define GST_PAD_CHAINLISTFUNC(pad)      (GST_PAD_CAST(pad)->chainlistfunc)
834 /**
835  * GST_PAD_GETRANGEFUNC:
836  * @pad: a #GstPad
837  *
838  * Get the #GstPadGetRangeFunction from the given @pad.
839  */
840 #define GST_PAD_GETRANGEFUNC(pad)       (GST_PAD_CAST(pad)->getrangefunc)
841 /**
842  * GST_PAD_EVENTFUNC:
843  * @pad: a #GstPad
844  *
845  * Get the #GstPadEventFunction from the given @pad, which
846  * is the function that handles events on the pad. You can
847  * use this to set your own event handling function on a pad
848  * after you create it.  If your element derives from a base
849  * class, use the base class's virtual functions instead.
850  */
851 #define GST_PAD_EVENTFUNC(pad)          (GST_PAD_CAST(pad)->eventfunc)
852 /**
853  * GST_PAD_QUERYFUNC:
854  * @pad: a #GstPad
855  *
856  * Get the #GstPadQueryFunction from @pad, which is the function
857  * that handles queries on the pad. You can  use this to set your
858  * own query handling function on a pad after you create it. If your
859  * element derives from a base class, use the base class's virtual
860  * functions instead.
861  */
862 #define GST_PAD_QUERYFUNC(pad)          (GST_PAD_CAST(pad)->queryfunc)
863 /**
864  * GST_PAD_ITERINTLINKFUNC:
865  * @pad: a #GstPad
866  *
867  * Get the #GstPadIterIntLinkFunction from the given @pad.
868  */
869 #define GST_PAD_ITERINTLINKFUNC(pad)    (GST_PAD_CAST(pad)->iterintlinkfunc)
870 /**
871  * GST_PAD_PEER:
872  * @pad: a #GstPad
873  *
874  * Return the pad's peer member. This member is a pointer to the linked @pad.
875  * No locking is performed in this function, use gst_pad_get_peer() instead.
876  */
877 #define GST_PAD_PEER(pad)               (GST_PAD_CAST(pad)->peer)
878 /**
879  * GST_PAD_LINKFUNC:
880  * @pad: a #GstPad
881  *
882  * Get the #GstPadLinkFunction for the given @pad.
883  */
884 #define GST_PAD_LINKFUNC(pad)           (GST_PAD_CAST(pad)->linkfunc)
885 /**
886  * GST_PAD_UNLINKFUNC:
887  * @pad: a #GstPad
888  *
889  * Get the #GstPadUnlinkFunction from the given @pad.
890  */
891 #define GST_PAD_UNLINKFUNC(pad)         (GST_PAD_CAST(pad)->unlinkfunc)
892 /**
893  * GST_PAD_IS_SRC:
894  * @pad: a #GstPad
895  *
896  * Returns: TRUE if the pad is a source pad (i.e. produces data).
897  */
898 #define GST_PAD_IS_SRC(pad)             (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
899 /**
900  * GST_PAD_IS_SINK:
901  * @pad: a #GstPad
902  *
903  * Returns: TRUE if the pad is a sink pad (i.e. consumes data).
904  */
905 #define GST_PAD_IS_SINK(pad)            (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
906 /**
907  * GST_PAD_IS_LINKED:
908  * @pad: a #GstPad
909  *
910  * Returns: TRUE if the pad is linked to another pad. Use gst_pad_is_linked()
911  * instead.
912  */
913 #define GST_PAD_IS_LINKED(pad)          (GST_PAD_PEER(pad) != NULL)
914 /**
915  * GST_PAD_IS_ACTIVE:
916  * @pad: a #GstPad
917  *
918  * Returns: TRUE if the pad has been activated.
919  */
920 #define GST_PAD_IS_ACTIVE(pad)          (GST_PAD_MODE(pad) != GST_PAD_MODE_NONE)
921 /**
922  * GST_PAD_IS_BLOCKED:
923  * @pad: a #GstPad
924  *
925  * Check if the dataflow on a @pad is blocked. Use gst_pad_is_blocked() instead.
926  */
927 #define GST_PAD_IS_BLOCKED(pad)         (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKED))
928 /**
929  * GST_PAD_IS_BLOCKING:
930  * @pad: a #GstPad
931  *
932  * Check if the @pad is currently blocking on a buffer or event. Use
933  * gst_pad_is_blocking() instead.
934  */
935 #define GST_PAD_IS_BLOCKING(pad)        (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKING))
936 /**
937  * GST_PAD_IS_FLUSHING:
938  * @pad: a #GstPad
939  *
940  * Check if the given @pad is flushing.
941  */
942 #define GST_PAD_IS_FLUSHING(pad)        (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FLUSHING))
943 /**
944  * GST_PAD_SET_FLUSHING:
945  * @pad: a #GstPad
946  *
947  * Set the given @pad to flushing state, which means it will not accept any
948  * more events, queries or buffers, and return GST_FLOW_FLUSHING if any buffers
949  * are pushed on it. This usually happens when the pad is shut down or when
950  * a flushing seek happens. This is used inside GStreamer when flush start/stop
951  * events pass through pads, or when an element state is changed and pads are
952  * activated or deactivated.
953  */
954 #define GST_PAD_SET_FLUSHING(pad)       (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_FLUSHING))
955 /**
956  * GST_PAD_UNSET_FLUSHING:
957  * @pad: a #GstPad
958  *
959  * Unset the flushing flag.
960  */
961 #define GST_PAD_UNSET_FLUSHING(pad)     (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_FLUSHING))
962 /**
963  * GST_PAD_IS_EOS:
964  * @pad: a #GstPad
965  *
966  * Check if the @pad is in EOS state.
967  */
968 #define GST_PAD_IS_EOS(pad)             (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_EOS))
969 /**
970  * GST_PAD_NEEDS_RECONFIGURE:
971  * @pad: a #GstPad
972  *
973  * Check if the @pad should be reconfigured/renegotiated.
974  * The flag has to be unset manually after reconfiguration happened.
975  * Use gst_pad_needs_reconfigure() or gst_pad_check_reconfigure() instead.
976  */
977 #define GST_PAD_NEEDS_RECONFIGURE(pad)  (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_NEED_RECONFIGURE))
978 /**
979  * GST_PAD_HAS_PENDING_EVENTS:
980  * @pad: a #GstPad
981  *
982  * Check if the given @pad has pending events. This is used internally by
983  * GStreamer.
984  */
985 #define GST_PAD_HAS_PENDING_EVENTS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PENDING_EVENTS))
986 /**
987  * GST_PAD_IS_FIXED_CAPS:
988  * @pad: a #GstPad
989  *
990  * Check if the given @pad is using fixed caps, which means that
991  * once the caps are set on the @pad, the caps query function will
992  * only return those caps. See gst_pad_use_fixed_caps().
993  */
994 #define GST_PAD_IS_FIXED_CAPS(pad)      (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FIXED_CAPS))
995 /**
996  * GST_PAD_NEEDS_PARENT:
997  * @pad: a #GstPad
998  *
999  * Check if there is a parent object before calling into the @pad callbacks.
1000  * This is used internally by GStreamer.
1001  */
1002 #define GST_PAD_NEEDS_PARENT(pad)       (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_NEED_PARENT))
1003 /**
1004  * GST_PAD_IS_PROXY_CAPS:
1005  * @pad: a #GstPad
1006  *
1007  * Check if the given @pad is set to proxy caps. This means that the default
1008  * event and query handler will forward all events and queries to the
1009  * internally linked @pads instead of discarding them.
1010  */
1011 #define GST_PAD_IS_PROXY_CAPS(pad)      (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PROXY_CAPS))
1012 /**
1013  * GST_PAD_SET_PROXY_CAPS:
1014  * @pad: a #GstPad
1015  *
1016  * Set @pad to proxy caps, so that all caps-related events and queries are
1017  * proxied down- or upstream to the other side of the element automatically.
1018  * Set this if the element always outputs data in the exact same format as it
1019  * receives as input. This is just for convenience to avoid implementing some
1020  * standard event and query handling code in an element.
1021  */
1022 #define GST_PAD_SET_PROXY_CAPS(pad)     (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PROXY_CAPS))
1023 /**
1024  * GST_PAD_UNSET_PROXY_CAPS:
1025  * @pad: a #GstPad
1026  *
1027  * Unset proxy caps flag.
1028  */
1029 #define GST_PAD_UNSET_PROXY_CAPS(pad)   (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PROXY_CAPS))
1030 /**
1031  * GST_PAD_IS_PROXY_ALLOCATION:
1032  * @pad: a #GstPad
1033  *
1034  * Check if the given @pad is set as proxy allocation which means
1035  * that the default query handler will forward allocation queries to the
1036  * internally linked @pads instead of discarding them.
1037  */
1038 #define GST_PAD_IS_PROXY_ALLOCATION(pad)    (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PROXY_ALLOCATION))
1039 /**
1040  * GST_PAD_SET_PROXY_ALLOCATION:
1041  * @pad: a #GstPad
1042  *
1043  * Set @pad to proxy allocation queries, which means that the default query
1044  * handler will forward allocation queries to the internally linked @pads
1045  * instead of discarding them.
1046  * Set this if the element always outputs data in the exact same format as it
1047  * receives as input. This is just for convenience to avoid implementing some
1048  * standard query handling code in an element.
1049  */
1050 #define GST_PAD_SET_PROXY_ALLOCATION(pad)   (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PROXY_ALLOCATION))
1051 /**
1052  * GST_PAD_UNSET_PROXY_ALLOCATION:
1053  * @pad: a #GstPad
1054  *
1055  * Unset proxy allocation flag.
1056  */
1057 #define GST_PAD_UNSET_PROXY_ALLOCATION(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PROXY_ALLOCATION))
1058 /**
1059  * GST_PAD_IS_PROXY_SCHEDULING:
1060  * @pad: a #GstPad
1061  *
1062  * Check if the given @pad is set to proxy scheduling queries, which means that
1063  * the default query handler will forward scheduling queries to the internally
1064  * linked @pads instead of discarding them.
1065  */
1066 #define GST_PAD_IS_PROXY_SCHEDULING(pad)    (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PROXY_SCHEDULING))
1067 /**
1068  * GST_PAD_SET_PROXY_SCHEDULING:
1069  * @pad: a #GstPad
1070  *
1071  * Set @pad to proxy scheduling queries, which means that the default query
1072  * handler will forward scheduling queries to the internally linked @pads
1073  * instead of discarding them. You will usually want to handle scheduling
1074  * queries explicitly if your element supports multiple scheduling modes.
1075  */
1076 #define GST_PAD_SET_PROXY_SCHEDULING(pad)   (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PROXY_SCHEDULING))
1077 /**
1078  * GST_PAD_UNSET_PROXY_SCHEDULING:
1079  * @pad: a #GstPad
1080  *
1081  * Unset proxy scheduling flag.
1082  */
1083 #define GST_PAD_UNSET_PROXY_SCHEDULING(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PROXY_SCHEDULING))
1084 /**
1085  * GST_PAD_IS_ACCEPT_INTERSECT:
1086  * @pad: a #GstPad
1087  *
1088  * Check if the pad's accept intersect flag is set. The default accept-caps
1089  * handler will check it the caps intersect the query-caps result instead of
1090  * checking for a subset. This is interesting for parser elements that can
1091  * accept incompletely specified caps.
1092  */
1093 #define GST_PAD_IS_ACCEPT_INTERSECT(pad)    (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT))
1094 /**
1095  * GST_PAD_SET_ACCEPT_INTERSECT:
1096  * @pad: a #GstPad
1097  *
1098  * Set @pad to by default accept caps by intersecting the result instead of
1099  * checking for a subset. This is interesting for parser elements that can
1100  * accept incompletely specified caps.
1101  */
1102 #define GST_PAD_SET_ACCEPT_INTERSECT(pad)   (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT))
1103 /**
1104  * GST_PAD_UNSET_ACCEPT_INTERSECT:
1105  * @pad: a #GstPad
1106  *
1107  * Unset accept intersect flag.
1108  */
1109 #define GST_PAD_UNSET_ACCEPT_INTERSECT(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT))
1110 /**
1111  * GST_PAD_GET_STREAM_LOCK:
1112  * @pad: a #GstPad
1113  *
1114  * Get the stream lock of @pad. The stream lock is protecting the
1115  * resources used in the data processing functions of @pad. Accessor
1116  * macro, use GST_PAD_STREAM_LOCK() and GST_PAD_STREAM_UNLOCK() instead
1117  * to take/release the pad's stream lock.
1118  */
1119 #define GST_PAD_GET_STREAM_LOCK(pad)    (&(GST_PAD_CAST(pad)->stream_rec_lock))
1120 /**
1121  * GST_PAD_STREAM_LOCK:
1122  * @pad: a #GstPad
1123  *
1124  * Take the pad's stream lock. The stream lock is recursive and will be taken
1125  * when buffers or serialized downstream events are pushed on a pad.
1126  */
1127 #define GST_PAD_STREAM_LOCK(pad)        g_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad))
1128 /**
1129  * GST_PAD_STREAM_TRYLOCK:
1130  * @pad: a #GstPad
1131  *
1132  * Try to take the pad's stream lock, and return TRUE if the lock could be
1133  * taken, and otherwise FALSE.
1134  */
1135 #define GST_PAD_STREAM_TRYLOCK(pad)     g_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad))
1136 /**
1137  * GST_PAD_STREAM_UNLOCK:
1138  * @pad: a #GstPad
1139  *
1140  * Release the pad's stream lock.
1141  */
1142 #define GST_PAD_STREAM_UNLOCK(pad)      g_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad))
1143
1144 #define GST_PAD_BLOCK_GET_COND(pad)     (&GST_PAD_CAST(pad)->block_cond)
1145 #define GST_PAD_BLOCK_WAIT(pad)         (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad)))
1146 #define GST_PAD_BLOCK_SIGNAL(pad)       (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad)))
1147 #define GST_PAD_BLOCK_BROADCAST(pad)    (g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad)))
1148
1149 GType                   gst_pad_get_type                        (void);
1150
1151 /* creating pads */
1152 GstPad*                 gst_pad_new                             (const gchar *name, GstPadDirection direction);
1153 GstPad*                 gst_pad_new_from_template               (GstPadTemplate *templ, const gchar *name);
1154 GstPad*                 gst_pad_new_from_static_template        (GstStaticPadTemplate *templ, const gchar *name);
1155
1156
1157 /**
1158  * gst_pad_get_name:
1159  * @pad: the pad to get the name from
1160  *
1161  * Get a copy of the name of the pad. g_free() after usage.
1162  *
1163  * MT safe.
1164  */
1165 #define gst_pad_get_name(pad) gst_object_get_name (GST_OBJECT_CAST (pad))
1166 /**
1167  * gst_pad_get_parent:
1168  * @pad: the pad to get the parent of
1169  *
1170  * Get the parent of @pad. This function increases the refcount
1171  * of the parent object so you should gst_object_unref() it after usage.
1172  * Can return NULL if the pad did not have a parent.
1173  *
1174  * MT safe.
1175  */
1176 #define gst_pad_get_parent(pad) gst_object_get_parent (GST_OBJECT_CAST (pad))
1177
1178 GstPadDirection         gst_pad_get_direction                   (GstPad *pad);
1179
1180 gboolean                gst_pad_set_active                      (GstPad *pad, gboolean active);
1181 gboolean                gst_pad_is_active                       (GstPad *pad);
1182 gboolean                gst_pad_activate_mode                   (GstPad *pad, GstPadMode mode,
1183                                                                  gboolean active);
1184
1185 gulong                  gst_pad_add_probe                       (GstPad *pad,
1186                                                                  GstPadProbeType mask,
1187                                                                  GstPadProbeCallback callback,
1188                                                                  gpointer user_data,
1189                                                                  GDestroyNotify destroy_data);
1190 void                    gst_pad_remove_probe                    (GstPad *pad, gulong id);
1191
1192 gboolean                gst_pad_is_blocked                      (GstPad *pad);
1193 gboolean                gst_pad_is_blocking                     (GstPad *pad);
1194
1195 void                    gst_pad_mark_reconfigure                (GstPad *pad);
1196 gboolean                gst_pad_needs_reconfigure               (GstPad *pad);
1197 gboolean                gst_pad_check_reconfigure               (GstPad *pad);
1198
1199 void                    gst_pad_set_element_private             (GstPad *pad, gpointer priv);
1200 gpointer                gst_pad_get_element_private             (GstPad *pad);
1201
1202 GstPadTemplate*         gst_pad_get_pad_template                (GstPad *pad);
1203
1204 GstFlowReturn           gst_pad_store_sticky_event              (GstPad *pad, GstEvent *event);
1205 GstEvent*               gst_pad_get_sticky_event                (GstPad *pad, GstEventType event_type,
1206                                                                  guint idx);
1207 void                    gst_pad_sticky_events_foreach           (GstPad *pad, GstPadStickyEventsForeachFunction foreach_func, gpointer user_data);
1208
1209 /* data passing setup functions */
1210 void                    gst_pad_set_activate_function_full      (GstPad *pad,
1211                                                                  GstPadActivateFunction activate,
1212                                                                  gpointer user_data,
1213                                                                  GDestroyNotify notify);
1214 void                    gst_pad_set_activatemode_function_full  (GstPad *pad,
1215                                                                  GstPadActivateModeFunction activatemode,
1216                                                                  gpointer user_data,
1217                                                                  GDestroyNotify notify);
1218 /* data passing functions */
1219 void                    gst_pad_set_chain_function_full         (GstPad *pad,
1220                                                                  GstPadChainFunction chain,
1221                                                                  gpointer user_data,
1222                                                                  GDestroyNotify notify);
1223 void                    gst_pad_set_chain_list_function_full    (GstPad *pad,
1224                                                                  GstPadChainListFunction chainlist,
1225                                                                  gpointer user_data,
1226                                                                  GDestroyNotify notify);
1227 void                    gst_pad_set_getrange_function_full      (GstPad *pad,
1228                                                                  GstPadGetRangeFunction get,
1229                                                                  gpointer user_data,
1230                                                                  GDestroyNotify notify);
1231 void                    gst_pad_set_event_function_full         (GstPad *pad,
1232                                                                  GstPadEventFunction event,
1233                                                                  gpointer user_data,
1234                                                                  GDestroyNotify notify);
1235
1236 #define gst_pad_set_activate_function(p,f)      gst_pad_set_activate_function_full((p),(f),NULL,NULL)
1237 #define gst_pad_set_activatemode_function(p,f)  gst_pad_set_activatemode_function_full((p),(f),NULL,NULL)
1238 #define gst_pad_set_chain_function(p,f)         gst_pad_set_chain_function_full((p),(f),NULL,NULL)
1239 #define gst_pad_set_chain_list_function(p,f)    gst_pad_set_chain_list_function_full((p),(f),NULL,NULL)
1240 #define gst_pad_set_getrange_function(p,f)      gst_pad_set_getrange_function_full((p),(f),NULL,NULL)
1241 #define gst_pad_set_event_function(p,f)         gst_pad_set_event_function_full((p),(f),NULL,NULL)
1242
1243 /* pad links */
1244 void                    gst_pad_set_link_function_full          (GstPad *pad,
1245                                                                  GstPadLinkFunction link,
1246                                                                  gpointer user_data,
1247                                                                  GDestroyNotify notify);
1248 void                    gst_pad_set_unlink_function_full        (GstPad *pad,
1249                                                                  GstPadUnlinkFunction unlink,
1250                                                                  gpointer user_data,
1251                                                                  GDestroyNotify notify);
1252
1253 #define gst_pad_set_link_function(p,f)          gst_pad_set_link_function_full((p),(f),NULL,NULL)
1254 #define gst_pad_set_unlink_function(p,f)        gst_pad_set_unlink_function_full((p),(f),NULL,NULL)
1255
1256 gboolean                gst_pad_can_link                        (GstPad *srcpad, GstPad *sinkpad);
1257 GstPadLinkReturn        gst_pad_link                            (GstPad *srcpad, GstPad *sinkpad);
1258 GstPadLinkReturn        gst_pad_link_full                       (GstPad *srcpad, GstPad *sinkpad, GstPadLinkCheck flags);
1259 gboolean                gst_pad_unlink                          (GstPad *srcpad, GstPad *sinkpad);
1260 gboolean                gst_pad_is_linked                       (GstPad *pad);
1261
1262 GstPad*                 gst_pad_get_peer                        (GstPad *pad);
1263
1264 GstCaps*                gst_pad_get_pad_template_caps           (GstPad *pad);
1265
1266 /* capsnego function for linked/unlinked pads */
1267 GstCaps *               gst_pad_get_current_caps                (GstPad * pad);
1268 gboolean                gst_pad_has_current_caps                (GstPad * pad);
1269
1270 /* capsnego for linked pads */
1271 GstCaps *               gst_pad_get_allowed_caps                (GstPad * pad);
1272
1273 /* pad offsets */
1274 gint64                  gst_pad_get_offset                      (GstPad *pad);
1275 void                    gst_pad_set_offset                      (GstPad *pad, gint64 offset);
1276
1277 /* data passing functions to peer */
1278 GstFlowReturn           gst_pad_push                            (GstPad *pad, GstBuffer *buffer);
1279 GstFlowReturn           gst_pad_push_list                       (GstPad *pad, GstBufferList *list);
1280 GstFlowReturn           gst_pad_pull_range                      (GstPad *pad, guint64 offset, guint size,
1281                                                                  GstBuffer **buffer);
1282 gboolean                gst_pad_push_event                      (GstPad *pad, GstEvent *event);
1283 gboolean                gst_pad_event_default                   (GstPad *pad, GstObject *parent,
1284                                                                  GstEvent *event);
1285
1286 /* data passing functions on pad */
1287 GstFlowReturn           gst_pad_chain                           (GstPad *pad, GstBuffer *buffer);
1288 GstFlowReturn           gst_pad_chain_list                      (GstPad *pad, GstBufferList *list);
1289 GstFlowReturn           gst_pad_get_range                       (GstPad *pad, guint64 offset, guint size,
1290                                                                  GstBuffer **buffer);
1291 gboolean                gst_pad_send_event                      (GstPad *pad, GstEvent *event);
1292
1293 /* pad tasks */
1294 gboolean                gst_pad_start_task                      (GstPad *pad, GstTaskFunction func,
1295                                                                  gpointer user_data, GDestroyNotify notify);
1296 gboolean                gst_pad_pause_task                      (GstPad *pad);
1297 gboolean                gst_pad_stop_task                       (GstPad *pad);
1298
1299 /* internal links */
1300 void                    gst_pad_set_iterate_internal_links_function_full (GstPad * pad,
1301                                                                  GstPadIterIntLinkFunction iterintlink,
1302                                                                  gpointer user_data,
1303                                                                  GDestroyNotify notify);
1304 GstIterator *           gst_pad_iterate_internal_links          (GstPad * pad);
1305 GstIterator *           gst_pad_iterate_internal_links_default  (GstPad * pad, GstObject *parent);
1306
1307 #define gst_pad_set_iterate_internal_links_function(p,f) gst_pad_set_iterate_internal_links_function_full((p),(f),NULL,NULL)
1308
1309 /* generic query function */
1310 gboolean                gst_pad_query                           (GstPad *pad, GstQuery *query);
1311 gboolean                gst_pad_peer_query                      (GstPad *pad, GstQuery *query);
1312 void                    gst_pad_set_query_function_full         (GstPad *pad, GstPadQueryFunction query,
1313                                                                  gpointer user_data,
1314                                                                  GDestroyNotify notify);
1315 gboolean                gst_pad_query_default                   (GstPad *pad, GstObject *parent,
1316                                                                  GstQuery *query);
1317
1318 #define gst_pad_set_query_function(p,f)   gst_pad_set_query_function_full((p),(f),NULL,NULL)
1319
1320 /* misc helper functions */
1321 gboolean                gst_pad_forward                         (GstPad *pad, GstPadForwardFunction forward,
1322                                                                  gpointer user_data);
1323
1324 G_END_DECLS
1325
1326 #endif /* __GST_PAD_H__ */