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