docs: convert NULL, TRUE, and FALSE to %NULL, %TRUE, and %FALSE
[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   union {
730     gpointer _gst_reserved[GST_PADDING];
731     struct {
732       GstFlowReturn last_flowret;
733     } abi;
734   } ABI;
735 };
736
737 struct _GstPadClass {
738   GstObjectClass        parent_class;
739
740   /* signal callbacks */
741   void          (*linked)               (GstPad *pad, GstPad *peer);
742   void          (*unlinked)             (GstPad *pad, GstPad *peer);
743
744   /*< private >*/
745   gpointer _gst_reserved[GST_PADDING];
746 };
747
748
749 /***** helper macros *****/
750 /* GstPad */
751
752 /**
753  * GST_PAD_NAME:
754  * @pad: a #GstPad
755  *
756  * Get name of the given pad.
757  * No locking is performed in this function, use gst_pad_get_name() instead.
758  */
759 #define GST_PAD_NAME(pad)               (GST_OBJECT_NAME(pad))
760 /**
761  * GST_PAD_PARENT:
762  * @pad: a #GstPad
763  *
764  * Get the @pad parent.
765  * No locking is performed in this function, use gst_pad_get_parent() instead.
766  */
767 #define GST_PAD_PARENT(pad)             (GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad)))
768 /**
769  * GST_PAD_ELEMENT_PRIVATE:
770  * @pad: a #GstPad
771  *
772  * Get the private data of @pad, which is usually some pad- or stream-specific
773  * structure created by the element and set on the pad when creating it.
774  * No locking is performed in this function.
775  */
776 #define GST_PAD_ELEMENT_PRIVATE(pad)    (GST_PAD_CAST(pad)->element_private)
777 /**
778  * GST_PAD_PAD_TEMPLATE:
779  * @pad: a #GstPad
780  *
781  * Get the @pad #GstPadTemplate. It describes the possible media types
782  * a @pad or an element factory can handle.
783  */
784 #define GST_PAD_PAD_TEMPLATE(pad)       (GST_PAD_CAST(pad)->padtemplate)
785 /**
786  * GST_PAD_DIRECTION:
787  * @pad: a #GstPad
788  *
789  * Get the #GstPadDirection of the given @pad. Accessor macro, use
790  * gst_pad_get_direction() instead.
791  */
792 #define GST_PAD_DIRECTION(pad)          (GST_PAD_CAST(pad)->direction)
793 /**
794  * GST_PAD_TASK:
795  * @pad: a #GstPad
796  *
797  * Get the #GstTask of @pad. Accessor macro used by GStreamer. Use the
798  * gst_pad_start_task(), gst_pad_stop_task() and gst_pad_pause_task()
799  * functions instead.
800  */
801 #define GST_PAD_TASK(pad)               (GST_PAD_CAST(pad)->task)
802 /**
803  * GST_PAD_MODE:
804  * @pad: a #GstPad
805  *
806  * Get the #GstPadMode of pad, which will be GST_PAD_MODE_NONE if the pad
807  * has not been activated yet, and otherwise either GST_PAD_MODE_PUSH or
808  * GST_PAD_MODE_PULL depending on which mode the pad was activated in.
809  */
810 #define GST_PAD_MODE(pad)               (GST_PAD_CAST(pad)->mode)
811 /**
812  * GST_PAD_ACTIVATEFUNC:
813  * @pad: a #GstPad
814  *
815  * Get the #GstPadActivateFunction from @pad.
816  */
817 #define GST_PAD_ACTIVATEFUNC(pad)       (GST_PAD_CAST(pad)->activatefunc)
818 /**
819  * GST_PAD_ACTIVATEMODEFUNC:
820  * @pad: a #GstPad
821  *
822  * Get the #GstPadActivateModeFunction from the given @pad.
823  */
824 #define GST_PAD_ACTIVATEMODEFUNC(pad)   (GST_PAD_CAST(pad)->activatemodefunc)
825 /**
826  * GST_PAD_CHAINFUNC:
827  * @pad: a #GstPad
828  *
829  * Get the #GstPadChainFunction from the given @pad.
830  */
831 #define GST_PAD_CHAINFUNC(pad)          (GST_PAD_CAST(pad)->chainfunc)
832 /**
833  * GST_PAD_CHAINLISTFUNC:
834  * @pad: a #GstPad
835  *
836  * Get the #GstPadChainListFunction from the given @pad.
837  */
838 #define GST_PAD_CHAINLISTFUNC(pad)      (GST_PAD_CAST(pad)->chainlistfunc)
839 /**
840  * GST_PAD_GETRANGEFUNC:
841  * @pad: a #GstPad
842  *
843  * Get the #GstPadGetRangeFunction from the given @pad.
844  */
845 #define GST_PAD_GETRANGEFUNC(pad)       (GST_PAD_CAST(pad)->getrangefunc)
846 /**
847  * GST_PAD_EVENTFUNC:
848  * @pad: a #GstPad
849  *
850  * Get the #GstPadEventFunction from the given @pad, which
851  * is the function that handles events on the pad. You can
852  * use this to set your own event handling function on a pad
853  * after you create it.  If your element derives from a base
854  * class, use the base class's virtual functions instead.
855  */
856 #define GST_PAD_EVENTFUNC(pad)          (GST_PAD_CAST(pad)->eventfunc)
857 /**
858  * GST_PAD_QUERYFUNC:
859  * @pad: a #GstPad
860  *
861  * Get the #GstPadQueryFunction from @pad, which is the function
862  * that handles queries on the pad. You can  use this to set your
863  * own query handling function on a pad after you create it. If your
864  * element derives from a base class, use the base class's virtual
865  * functions instead.
866  */
867 #define GST_PAD_QUERYFUNC(pad)          (GST_PAD_CAST(pad)->queryfunc)
868 /**
869  * GST_PAD_ITERINTLINKFUNC:
870  * @pad: a #GstPad
871  *
872  * Get the #GstPadIterIntLinkFunction from the given @pad.
873  */
874 #define GST_PAD_ITERINTLINKFUNC(pad)    (GST_PAD_CAST(pad)->iterintlinkfunc)
875 /**
876  * GST_PAD_PEER:
877  * @pad: a #GstPad
878  *
879  * Return the pad's peer member. This member is a pointer to the linked @pad.
880  * No locking is performed in this function, use gst_pad_get_peer() instead.
881  */
882 #define GST_PAD_PEER(pad)               (GST_PAD_CAST(pad)->peer)
883 /**
884  * GST_PAD_LINKFUNC:
885  * @pad: a #GstPad
886  *
887  * Get the #GstPadLinkFunction for the given @pad.
888  */
889 #define GST_PAD_LINKFUNC(pad)           (GST_PAD_CAST(pad)->linkfunc)
890 /**
891  * GST_PAD_UNLINKFUNC:
892  * @pad: a #GstPad
893  *
894  * Get the #GstPadUnlinkFunction from the given @pad.
895  */
896 #define GST_PAD_UNLINKFUNC(pad)         (GST_PAD_CAST(pad)->unlinkfunc)
897 /**
898  * GST_PAD_IS_SRC:
899  * @pad: a #GstPad
900  *
901  * Returns: %TRUE if the pad is a source pad (i.e. produces data).
902  */
903 #define GST_PAD_IS_SRC(pad)             (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
904 /**
905  * GST_PAD_IS_SINK:
906  * @pad: a #GstPad
907  *
908  * Returns: %TRUE if the pad is a sink pad (i.e. consumes data).
909  */
910 #define GST_PAD_IS_SINK(pad)            (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
911 /**
912  * GST_PAD_IS_LINKED:
913  * @pad: a #GstPad
914  *
915  * Returns: %TRUE if the pad is linked to another pad. Use gst_pad_is_linked()
916  * instead.
917  */
918 #define GST_PAD_IS_LINKED(pad)          (GST_PAD_PEER(pad) != NULL)
919 /**
920  * GST_PAD_IS_ACTIVE:
921  * @pad: a #GstPad
922  *
923  * Returns: %TRUE if the pad has been activated.
924  */
925 #define GST_PAD_IS_ACTIVE(pad)          (GST_PAD_MODE(pad) != GST_PAD_MODE_NONE)
926 /**
927  * GST_PAD_IS_BLOCKED:
928  * @pad: a #GstPad
929  *
930  * Check if the dataflow on a @pad is blocked. Use gst_pad_is_blocked() instead.
931  */
932 #define GST_PAD_IS_BLOCKED(pad)         (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKED))
933 /**
934  * GST_PAD_IS_BLOCKING:
935  * @pad: a #GstPad
936  *
937  * Check if the @pad is currently blocking on a buffer or event. Use
938  * gst_pad_is_blocking() instead.
939  */
940 #define GST_PAD_IS_BLOCKING(pad)        (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKING))
941 /**
942  * GST_PAD_IS_FLUSHING:
943  * @pad: a #GstPad
944  *
945  * Check if the given @pad is flushing.
946  */
947 #define GST_PAD_IS_FLUSHING(pad)        (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FLUSHING))
948 /**
949  * GST_PAD_SET_FLUSHING:
950  * @pad: a #GstPad
951  *
952  * Set the given @pad to flushing state, which means it will not accept any
953  * more events, queries or buffers, and return GST_FLOW_FLUSHING if any buffers
954  * are pushed on it. This usually happens when the pad is shut down or when
955  * a flushing seek happens. This is used inside GStreamer when flush start/stop
956  * events pass through pads, or when an element state is changed and pads are
957  * activated or deactivated.
958  */
959 #define GST_PAD_SET_FLUSHING(pad)       (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_FLUSHING))
960 /**
961  * GST_PAD_UNSET_FLUSHING:
962  * @pad: a #GstPad
963  *
964  * Unset the flushing flag.
965  */
966 #define GST_PAD_UNSET_FLUSHING(pad)     (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_FLUSHING))
967 /**
968  * GST_PAD_IS_EOS:
969  * @pad: a #GstPad
970  *
971  * Check if the @pad is in EOS state.
972  */
973 #define GST_PAD_IS_EOS(pad)             (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_EOS))
974 /**
975  * GST_PAD_NEEDS_RECONFIGURE:
976  * @pad: a #GstPad
977  *
978  * Check if the @pad should be reconfigured/renegotiated.
979  * The flag has to be unset manually after reconfiguration happened.
980  * Use gst_pad_needs_reconfigure() or gst_pad_check_reconfigure() instead.
981  */
982 #define GST_PAD_NEEDS_RECONFIGURE(pad)  (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_NEED_RECONFIGURE))
983 /**
984  * GST_PAD_HAS_PENDING_EVENTS:
985  * @pad: a #GstPad
986  *
987  * Check if the given @pad has pending events. This is used internally by
988  * GStreamer.
989  */
990 #define GST_PAD_HAS_PENDING_EVENTS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PENDING_EVENTS))
991 /**
992  * GST_PAD_IS_FIXED_CAPS:
993  * @pad: a #GstPad
994  *
995  * Check if the given @pad is using fixed caps, which means that
996  * once the caps are set on the @pad, the caps query function will
997  * only return those caps. See gst_pad_use_fixed_caps().
998  */
999 #define GST_PAD_IS_FIXED_CAPS(pad)      (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FIXED_CAPS))
1000 /**
1001  * GST_PAD_NEEDS_PARENT:
1002  * @pad: a #GstPad
1003  *
1004  * Check if there is a parent object before calling into the @pad callbacks.
1005  * This is used internally by GStreamer.
1006  */
1007 #define GST_PAD_NEEDS_PARENT(pad)       (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_NEED_PARENT))
1008 /**
1009  * GST_PAD_IS_PROXY_CAPS:
1010  * @pad: a #GstPad
1011  *
1012  * Check if the given @pad is set to proxy caps. This means that the default
1013  * event and query handler will forward all events and queries to the
1014  * internally linked @pads instead of discarding them.
1015  */
1016 #define GST_PAD_IS_PROXY_CAPS(pad)      (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PROXY_CAPS))
1017 /**
1018  * GST_PAD_SET_PROXY_CAPS:
1019  * @pad: a #GstPad
1020  *
1021  * Set @pad to proxy caps, so that all caps-related events and queries are
1022  * proxied down- or upstream to the other side of the element automatically.
1023  * Set this if the element always outputs data in the exact same format as it
1024  * receives as input. This is just for convenience to avoid implementing some
1025  * standard event and query handling code in an element.
1026  */
1027 #define GST_PAD_SET_PROXY_CAPS(pad)     (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PROXY_CAPS))
1028 /**
1029  * GST_PAD_UNSET_PROXY_CAPS:
1030  * @pad: a #GstPad
1031  *
1032  * Unset proxy caps flag.
1033  */
1034 #define GST_PAD_UNSET_PROXY_CAPS(pad)   (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PROXY_CAPS))
1035 /**
1036  * GST_PAD_IS_PROXY_ALLOCATION:
1037  * @pad: a #GstPad
1038  *
1039  * Check if the given @pad is set as proxy allocation which means
1040  * that the default query handler will forward allocation queries to the
1041  * internally linked @pads instead of discarding them.
1042  */
1043 #define GST_PAD_IS_PROXY_ALLOCATION(pad)    (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PROXY_ALLOCATION))
1044 /**
1045  * GST_PAD_SET_PROXY_ALLOCATION:
1046  * @pad: a #GstPad
1047  *
1048  * Set @pad to proxy allocation queries, which means that the default query
1049  * handler will forward allocation queries to the internally linked @pads
1050  * instead of discarding them.
1051  * Set this if the element always outputs data in the exact same format as it
1052  * receives as input. This is just for convenience to avoid implementing some
1053  * standard query handling code in an element.
1054  */
1055 #define GST_PAD_SET_PROXY_ALLOCATION(pad)   (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PROXY_ALLOCATION))
1056 /**
1057  * GST_PAD_UNSET_PROXY_ALLOCATION:
1058  * @pad: a #GstPad
1059  *
1060  * Unset proxy allocation flag.
1061  */
1062 #define GST_PAD_UNSET_PROXY_ALLOCATION(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PROXY_ALLOCATION))
1063 /**
1064  * GST_PAD_IS_PROXY_SCHEDULING:
1065  * @pad: a #GstPad
1066  *
1067  * Check if the given @pad is set to proxy scheduling queries, which means that
1068  * the default query handler will forward scheduling queries to the internally
1069  * linked @pads instead of discarding them.
1070  */
1071 #define GST_PAD_IS_PROXY_SCHEDULING(pad)    (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PROXY_SCHEDULING))
1072 /**
1073  * GST_PAD_SET_PROXY_SCHEDULING:
1074  * @pad: a #GstPad
1075  *
1076  * Set @pad to proxy scheduling queries, which means that the default query
1077  * handler will forward scheduling queries to the internally linked @pads
1078  * instead of discarding them. You will usually want to handle scheduling
1079  * queries explicitly if your element supports multiple scheduling modes.
1080  */
1081 #define GST_PAD_SET_PROXY_SCHEDULING(pad)   (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PROXY_SCHEDULING))
1082 /**
1083  * GST_PAD_UNSET_PROXY_SCHEDULING:
1084  * @pad: a #GstPad
1085  *
1086  * Unset proxy scheduling flag.
1087  */
1088 #define GST_PAD_UNSET_PROXY_SCHEDULING(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PROXY_SCHEDULING))
1089 /**
1090  * GST_PAD_IS_ACCEPT_INTERSECT:
1091  * @pad: a #GstPad
1092  *
1093  * Check if the pad's accept intersect flag is set. The default accept-caps
1094  * handler will check it the caps intersect the query-caps result instead of
1095  * checking for a subset. This is interesting for parser elements that can
1096  * accept incompletely specified caps.
1097  */
1098 #define GST_PAD_IS_ACCEPT_INTERSECT(pad)    (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT))
1099 /**
1100  * GST_PAD_SET_ACCEPT_INTERSECT:
1101  * @pad: a #GstPad
1102  *
1103  * Set @pad to by default accept caps by intersecting the result instead of
1104  * checking for a subset. This is interesting for parser elements that can
1105  * accept incompletely specified caps.
1106  */
1107 #define GST_PAD_SET_ACCEPT_INTERSECT(pad)   (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT))
1108 /**
1109  * GST_PAD_UNSET_ACCEPT_INTERSECT:
1110  * @pad: a #GstPad
1111  *
1112  * Unset accept intersect flag.
1113  */
1114 #define GST_PAD_UNSET_ACCEPT_INTERSECT(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_ACCEPT_INTERSECT))
1115 /**
1116  * GST_PAD_GET_STREAM_LOCK:
1117  * @pad: a #GstPad
1118  *
1119  * Get the stream lock of @pad. The stream lock is protecting the
1120  * resources used in the data processing functions of @pad. Accessor
1121  * macro, use GST_PAD_STREAM_LOCK() and GST_PAD_STREAM_UNLOCK() instead
1122  * to take/release the pad's stream lock.
1123  */
1124 #define GST_PAD_GET_STREAM_LOCK(pad)    (&(GST_PAD_CAST(pad)->stream_rec_lock))
1125 /**
1126  * GST_PAD_STREAM_LOCK:
1127  * @pad: a #GstPad
1128  *
1129  * Take the pad's stream lock. The stream lock is recursive and will be taken
1130  * when buffers or serialized downstream events are pushed on a pad.
1131  */
1132 #define GST_PAD_STREAM_LOCK(pad)        g_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad))
1133 /**
1134  * GST_PAD_STREAM_TRYLOCK:
1135  * @pad: a #GstPad
1136  *
1137  * Try to take the pad's stream lock, and return %TRUE if the lock could be
1138  * taken, and otherwise %FALSE.
1139  */
1140 #define GST_PAD_STREAM_TRYLOCK(pad)     g_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad))
1141 /**
1142  * GST_PAD_STREAM_UNLOCK:
1143  * @pad: a #GstPad
1144  *
1145  * Release the pad's stream lock.
1146  */
1147 #define GST_PAD_STREAM_UNLOCK(pad)      g_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad))
1148 /**
1149  * GST_PAD_LAST_FLOW_RETURN:
1150  * @pad: a #GstPad
1151  *
1152  * Gets the last flow return on this pad
1153  *
1154  * Since: 1.4
1155  */
1156 #define GST_PAD_LAST_FLOW_RETURN(pad)   (GST_PAD_CAST(pad)->ABI.abi.last_flowret)
1157
1158 #define GST_PAD_BLOCK_GET_COND(pad)     (&GST_PAD_CAST(pad)->block_cond)
1159 #define GST_PAD_BLOCK_WAIT(pad)         (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad)))
1160 #define GST_PAD_BLOCK_SIGNAL(pad)       (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad)))
1161 #define GST_PAD_BLOCK_BROADCAST(pad)    (g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad)))
1162
1163 GType                   gst_pad_get_type                        (void);
1164
1165 /* creating pads */
1166 GstPad*                 gst_pad_new                             (const gchar *name, GstPadDirection direction);
1167 GstPad*                 gst_pad_new_from_template               (GstPadTemplate *templ, const gchar *name);
1168 GstPad*                 gst_pad_new_from_static_template        (GstStaticPadTemplate *templ, const gchar *name);
1169
1170
1171 /**
1172  * gst_pad_get_name:
1173  * @pad: the pad to get the name from
1174  *
1175  * Get a copy of the name of the pad. g_free() after usage.
1176  *
1177  * MT safe.
1178  */
1179 #define gst_pad_get_name(pad) gst_object_get_name (GST_OBJECT_CAST (pad))
1180 /**
1181  * gst_pad_get_parent:
1182  * @pad: the pad to get the parent of
1183  *
1184  * Get the parent of @pad. This function increases the refcount
1185  * of the parent object so you should gst_object_unref() it after usage.
1186  * Can return %NULL if the pad did not have a parent.
1187  *
1188  * MT safe.
1189  */
1190 #define gst_pad_get_parent(pad) gst_object_get_parent (GST_OBJECT_CAST (pad))
1191
1192 GstPadDirection         gst_pad_get_direction                   (GstPad *pad);
1193
1194 gboolean                gst_pad_set_active                      (GstPad *pad, gboolean active);
1195 gboolean                gst_pad_is_active                       (GstPad *pad);
1196 gboolean                gst_pad_activate_mode                   (GstPad *pad, GstPadMode mode,
1197                                                                  gboolean active);
1198
1199 gulong                  gst_pad_add_probe                       (GstPad *pad,
1200                                                                  GstPadProbeType mask,
1201                                                                  GstPadProbeCallback callback,
1202                                                                  gpointer user_data,
1203                                                                  GDestroyNotify destroy_data);
1204 void                    gst_pad_remove_probe                    (GstPad *pad, gulong id);
1205
1206 gboolean                gst_pad_is_blocked                      (GstPad *pad);
1207 gboolean                gst_pad_is_blocking                     (GstPad *pad);
1208
1209 void                    gst_pad_mark_reconfigure                (GstPad *pad);
1210 gboolean                gst_pad_needs_reconfigure               (GstPad *pad);
1211 gboolean                gst_pad_check_reconfigure               (GstPad *pad);
1212
1213 void                    gst_pad_set_element_private             (GstPad *pad, gpointer priv);
1214 gpointer                gst_pad_get_element_private             (GstPad *pad);
1215
1216 GstPadTemplate*         gst_pad_get_pad_template                (GstPad *pad);
1217
1218 GstFlowReturn           gst_pad_store_sticky_event              (GstPad *pad, GstEvent *event);
1219 GstEvent*               gst_pad_get_sticky_event                (GstPad *pad, GstEventType event_type,
1220                                                                  guint idx);
1221 void                    gst_pad_sticky_events_foreach           (GstPad *pad, GstPadStickyEventsForeachFunction foreach_func, gpointer user_data);
1222
1223 /* data passing setup functions */
1224 void                    gst_pad_set_activate_function_full      (GstPad *pad,
1225                                                                  GstPadActivateFunction activate,
1226                                                                  gpointer user_data,
1227                                                                  GDestroyNotify notify);
1228 void                    gst_pad_set_activatemode_function_full  (GstPad *pad,
1229                                                                  GstPadActivateModeFunction activatemode,
1230                                                                  gpointer user_data,
1231                                                                  GDestroyNotify notify);
1232 /* data passing functions */
1233 void                    gst_pad_set_chain_function_full         (GstPad *pad,
1234                                                                  GstPadChainFunction chain,
1235                                                                  gpointer user_data,
1236                                                                  GDestroyNotify notify);
1237 void                    gst_pad_set_chain_list_function_full    (GstPad *pad,
1238                                                                  GstPadChainListFunction chainlist,
1239                                                                  gpointer user_data,
1240                                                                  GDestroyNotify notify);
1241 void                    gst_pad_set_getrange_function_full      (GstPad *pad,
1242                                                                  GstPadGetRangeFunction get,
1243                                                                  gpointer user_data,
1244                                                                  GDestroyNotify notify);
1245 void                    gst_pad_set_event_function_full         (GstPad *pad,
1246                                                                  GstPadEventFunction event,
1247                                                                  gpointer user_data,
1248                                                                  GDestroyNotify notify);
1249
1250 #define gst_pad_set_activate_function(p,f)      gst_pad_set_activate_function_full((p),(f),NULL,NULL)
1251 #define gst_pad_set_activatemode_function(p,f)  gst_pad_set_activatemode_function_full((p),(f),NULL,NULL)
1252 #define gst_pad_set_chain_function(p,f)         gst_pad_set_chain_function_full((p),(f),NULL,NULL)
1253 #define gst_pad_set_chain_list_function(p,f)    gst_pad_set_chain_list_function_full((p),(f),NULL,NULL)
1254 #define gst_pad_set_getrange_function(p,f)      gst_pad_set_getrange_function_full((p),(f),NULL,NULL)
1255 #define gst_pad_set_event_function(p,f)         gst_pad_set_event_function_full((p),(f),NULL,NULL)
1256
1257 /* pad links */
1258 void                    gst_pad_set_link_function_full          (GstPad *pad,
1259                                                                  GstPadLinkFunction link,
1260                                                                  gpointer user_data,
1261                                                                  GDestroyNotify notify);
1262 void                    gst_pad_set_unlink_function_full        (GstPad *pad,
1263                                                                  GstPadUnlinkFunction unlink,
1264                                                                  gpointer user_data,
1265                                                                  GDestroyNotify notify);
1266
1267 #define gst_pad_set_link_function(p,f)          gst_pad_set_link_function_full((p),(f),NULL,NULL)
1268 #define gst_pad_set_unlink_function(p,f)        gst_pad_set_unlink_function_full((p),(f),NULL,NULL)
1269
1270 gboolean                gst_pad_can_link                        (GstPad *srcpad, GstPad *sinkpad);
1271 GstPadLinkReturn        gst_pad_link                            (GstPad *srcpad, GstPad *sinkpad);
1272 GstPadLinkReturn        gst_pad_link_full                       (GstPad *srcpad, GstPad *sinkpad, GstPadLinkCheck flags);
1273 gboolean                gst_pad_unlink                          (GstPad *srcpad, GstPad *sinkpad);
1274 gboolean                gst_pad_is_linked                       (GstPad *pad);
1275
1276 GstPad*                 gst_pad_get_peer                        (GstPad *pad);
1277
1278 GstCaps*                gst_pad_get_pad_template_caps           (GstPad *pad);
1279
1280 /* capsnego function for linked/unlinked pads */
1281 GstCaps *               gst_pad_get_current_caps                (GstPad * pad);
1282 gboolean                gst_pad_has_current_caps                (GstPad * pad);
1283
1284 /* capsnego for linked pads */
1285 GstCaps *               gst_pad_get_allowed_caps                (GstPad * pad);
1286
1287 /* pad offsets */
1288 gint64                  gst_pad_get_offset                      (GstPad *pad);
1289 void                    gst_pad_set_offset                      (GstPad *pad, gint64 offset);
1290
1291 /* data passing functions to peer */
1292 GstFlowReturn           gst_pad_push                            (GstPad *pad, GstBuffer *buffer);
1293 GstFlowReturn           gst_pad_push_list                       (GstPad *pad, GstBufferList *list);
1294 GstFlowReturn           gst_pad_pull_range                      (GstPad *pad, guint64 offset, guint size,
1295                                                                  GstBuffer **buffer);
1296 gboolean                gst_pad_push_event                      (GstPad *pad, GstEvent *event);
1297 gboolean                gst_pad_event_default                   (GstPad *pad, GstObject *parent,
1298                                                                  GstEvent *event);
1299 GstFlowReturn           gst_pad_get_last_flow_return            (GstPad *pad);
1300
1301 /* data passing functions on pad */
1302 GstFlowReturn           gst_pad_chain                           (GstPad *pad, GstBuffer *buffer);
1303 GstFlowReturn           gst_pad_chain_list                      (GstPad *pad, GstBufferList *list);
1304 GstFlowReturn           gst_pad_get_range                       (GstPad *pad, guint64 offset, guint size,
1305                                                                  GstBuffer **buffer);
1306 gboolean                gst_pad_send_event                      (GstPad *pad, GstEvent *event);
1307
1308 /* pad tasks */
1309 gboolean                gst_pad_start_task                      (GstPad *pad, GstTaskFunction func,
1310                                                                  gpointer user_data, GDestroyNotify notify);
1311 gboolean                gst_pad_pause_task                      (GstPad *pad);
1312 gboolean                gst_pad_stop_task                       (GstPad *pad);
1313
1314 /* internal links */
1315 void                    gst_pad_set_iterate_internal_links_function_full (GstPad * pad,
1316                                                                  GstPadIterIntLinkFunction iterintlink,
1317                                                                  gpointer user_data,
1318                                                                  GDestroyNotify notify);
1319 GstIterator *           gst_pad_iterate_internal_links          (GstPad * pad);
1320 GstIterator *           gst_pad_iterate_internal_links_default  (GstPad * pad, GstObject *parent);
1321
1322 #define gst_pad_set_iterate_internal_links_function(p,f) gst_pad_set_iterate_internal_links_function_full((p),(f),NULL,NULL)
1323
1324 /* generic query function */
1325 gboolean                gst_pad_query                           (GstPad *pad, GstQuery *query);
1326 gboolean                gst_pad_peer_query                      (GstPad *pad, GstQuery *query);
1327 void                    gst_pad_set_query_function_full         (GstPad *pad, GstPadQueryFunction query,
1328                                                                  gpointer user_data,
1329                                                                  GDestroyNotify notify);
1330 gboolean                gst_pad_query_default                   (GstPad *pad, GstObject *parent,
1331                                                                  GstQuery *query);
1332
1333 #define gst_pad_set_query_function(p,f)   gst_pad_set_query_function_full((p),(f),NULL,NULL)
1334
1335 /* misc helper functions */
1336 gboolean                gst_pad_forward                         (GstPad *pad, GstPadForwardFunction forward,
1337                                                                  gpointer user_data);
1338
1339 G_END_DECLS
1340
1341 #endif /* __GST_PAD_H__ */