2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wim.taymans@chello.be>
5 * gstpad.h: Header for GstPad object
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.
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.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
27 #include <gst/gstconfig.h>
29 typedef struct _GstPad GstPad;
30 typedef struct _GstPadPrivate GstPadPrivate;
31 typedef struct _GstPadClass GstPadClass;
35 * @GST_PAD_UNKNOWN: direction is unknown.
36 * @GST_PAD_SRC: the pad is a source pad.
37 * @GST_PAD_SINK: the pad is a sink pad.
39 * The direction of a pad.
47 #include <gst/gstobject.h>
48 #include <gst/gstbuffer.h>
49 #include <gst/gstbufferlist.h>
50 #include <gst/gstcaps.h>
51 #include <gst/gstpadtemplate.h>
52 #include <gst/gstevent.h>
53 #include <gst/gstquery.h>
54 #include <gst/gsttask.h>
61 #define GST_TYPE_PAD (gst_pad_get_type ())
62 #define GST_IS_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD))
63 #define GST_IS_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD))
64 #define GST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad))
65 #define GST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass))
66 #define GST_PAD_CAST(obj) ((GstPad*)(obj))
72 * @GST_PAD_LINK_OK : link succeeded
73 * @GST_PAD_LINK_WRONG_HIERARCHY: pads have no common grandparent
74 * @GST_PAD_LINK_WAS_LINKED : pad was already linked
75 * @GST_PAD_LINK_WRONG_DIRECTION: pads have wrong direction
76 * @GST_PAD_LINK_NOFORMAT : pads do not have common format
77 * @GST_PAD_LINK_NOSCHED : pads cannot cooperate in scheduling
78 * @GST_PAD_LINK_REFUSED : refused for some reason
80 * Result values from gst_pad_link and friends.
84 GST_PAD_LINK_WRONG_HIERARCHY = -1,
85 GST_PAD_LINK_WAS_LINKED = -2,
86 GST_PAD_LINK_WRONG_DIRECTION = -3,
87 GST_PAD_LINK_NOFORMAT = -4,
88 GST_PAD_LINK_NOSCHED = -5,
89 GST_PAD_LINK_REFUSED = -6
93 * GST_PAD_LINK_FAILED:
94 * @ret: the #GstPadLinkReturn value
96 * Macro to test if the given #GstPadLinkReturn value indicates a failed
99 #define GST_PAD_LINK_FAILED(ret) ((ret) < GST_PAD_LINK_OK)
102 * GST_PAD_LINK_SUCCESSFUL:
103 * @ret: the #GstPadLinkReturn value
105 * Macro to test if the given #GstPadLinkReturn value indicates a successful
108 #define GST_PAD_LINK_SUCCESSFUL(ret) ((ret) >= GST_PAD_LINK_OK)
112 * @GST_FLOW_RESEND: Resend buffer, possibly with new caps (not
113 * sent yet) (unused/unimplemented).
114 * @GST_FLOW_OK: Data passing was ok.
115 * @GST_FLOW_NOT_LINKED: Pad is not linked.
116 * @GST_FLOW_WRONG_STATE: Pad is in wrong state.
117 * @GST_FLOW_EOS: Pad is EOS.
118 * @GST_FLOW_NOT_NEGOTIATED: Pad is not negotiated.
119 * @GST_FLOW_ERROR: Some (fatal) error occured. Element generating
120 * this error should post an error message with more
122 * @GST_FLOW_NOT_SUPPORTED: This operation is not supported.
123 * @GST_FLOW_CUSTOM_SUCCESS: Elements can use values starting from
124 * this (and higher) to define custom success
125 * codes. Since 0.10.7.
126 * @GST_FLOW_CUSTOM_SUCCESS_1: Pre-defined custom success code (define your
127 * custom success code to this to avoid compiler
128 * warnings). Since 0.10.29.
129 * @GST_FLOW_CUSTOM_SUCCESS_2: Pre-defined custom success code. Since 0.10.29.
130 * @GST_FLOW_CUSTOM_ERROR: Elements can use values starting from
131 * this (and lower) to define custom error codes.
133 * @GST_FLOW_CUSTOM_ERROR_1: Pre-defined custom error code (define your
134 * custom error code to this to avoid compiler
135 * warnings). Since 0.10.29.
136 * @GST_FLOW_CUSTOM_ERROR_2: Pre-defined custom error code. Since 0.10.29.
138 * The result of passing data to a pad.
140 * Note that the custom return values should not be exposed outside of the
141 * element scope and are available since 0.10.7.
143 /* FIXME 0.11: remove custom flow returns */
145 /* custom success starts here */
146 GST_FLOW_CUSTOM_SUCCESS_2 = 102,
147 GST_FLOW_CUSTOM_SUCCESS_1 = 101,
148 GST_FLOW_CUSTOM_SUCCESS = 100,
150 /* core predefined */
153 /* expected failures */
154 GST_FLOW_NOT_LINKED = -1,
155 GST_FLOW_WRONG_STATE = -2,
158 GST_FLOW_NOT_NEGOTIATED = -4,
160 GST_FLOW_NOT_SUPPORTED = -6,
162 /* custom error starts here */
163 GST_FLOW_CUSTOM_ERROR = -100,
164 GST_FLOW_CUSTOM_ERROR_1 = -101,
165 GST_FLOW_CUSTOM_ERROR_2 = -102
168 const gchar* gst_flow_get_name (GstFlowReturn ret);
169 GQuark gst_flow_to_quark (GstFlowReturn ret);
173 * @GST_PAD_LINK_CHECK_NOTHING: Don't check hierarchy or caps compatibility.
174 * @GST_PAD_LINK_CHECK_HIERARCHY: Check the pads have same parents/grandparents.
175 * Could be omitted if it is already known that the two elements that own the
176 * pads are in the same bin.
177 * @GST_PAD_LINK_CHECK_TEMPLATE_CAPS: Check if the pads are compatible by using
178 * their template caps. This is much faster than @GST_PAD_LINK_CHECK_CAPS, but
179 * would be unsafe e.g. if one pad has %GST_CAPS_ANY.
180 * @GST_PAD_LINK_CHECK_CAPS: Check if the pads are compatible by comparing the
181 * caps returned by gst_pad_query_caps().
183 * The amount of checking to be done when linking pads. @GST_PAD_LINK_CHECK_CAPS
184 * and @GST_PAD_LINK_CHECK_TEMPLATE_CAPS are mutually exclusive. If both are
185 * specified, expensive but safe @GST_PAD_LINK_CHECK_CAPS are performed.
188 * Only disable some of the checks if you are 100% certain you know the link
189 * will not fail because of hierarchy/caps compatibility failures. If uncertain,
190 * use the default checks (%GST_PAD_LINK_CHECK_DEFAULT) or the regular methods
191 * for linking the pads.
198 GST_PAD_LINK_CHECK_NOTHING = 0,
199 GST_PAD_LINK_CHECK_HIERARCHY = 1 << 0,
200 GST_PAD_LINK_CHECK_TEMPLATE_CAPS = 1 << 1,
201 GST_PAD_LINK_CHECK_CAPS = 1 << 2
205 * GST_PAD_LINK_CHECK_DEFAULT:
207 * The default checks done when linking pads (i.e. the ones used by
212 #define GST_PAD_LINK_CHECK_DEFAULT ((GstPadLinkCheck) (GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_CAPS))
216 * @GST_PAD_MODE_NONE: Pad will not handle dataflow
217 * @GST_PAD_MODE_PUSH: Pad handles dataflow in downstream push mode
218 * @GST_PAD_MODE_PULL: Pad handles dataflow in upstream pull mode
220 * The status of a GstPad. After activating a pad, which usually happens when the
221 * parent element goes from READY to PAUSED, the GstPadMode defines if the
222 * pad operates in push or pull mode.
232 * GstPadActivateFunction:
235 * This function is called when the pad is activated during the element
236 * READY to PAUSED state change. By default this function will call the
237 * activate function that puts the pad in push mode but elements can
238 * override this function to activate the pad in pull mode if they wish.
240 * Returns: TRUE if the pad could be activated.
242 typedef gboolean (*GstPadActivateFunction) (GstPad *pad, GstObject *parent);
244 * GstPadActivateModeFunction:
246 * @active: activate or deactivate the pad.
248 * The prototype of the push and pull activate functions.
250 * Returns: TRUE if the pad could be activated or deactivated.
252 typedef gboolean (*GstPadActivateModeFunction) (GstPad *pad, GstObject *parent,
258 * GstPadChainFunction:
259 * @pad: the sink #GstPad that performed the chain.
260 * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
261 * @parent is guaranteed to be not-NULL and remain valid during the
262 * execution of this function.
263 * @buffer: the #GstBuffer that is chained, not %NULL.
265 * A function that will be called on sinkpads when chaining buffers.
266 * The function typically processes the data contained in the buffer and
267 * either consumes the data or passes it on to the internally linked pad(s).
269 * The implementer of this function receives a refcount to @buffer and should
270 * gst_buffer_unref() when the buffer is no longer needed.
272 * When a chain function detects an error in the data stream, it must post an
273 * error on the bus and return an appropriate #GstFlowReturn value.
275 * Returns: #GST_FLOW_OK for success
277 typedef GstFlowReturn (*GstPadChainFunction) (GstPad *pad, GstObject *parent,
281 * GstPadChainListFunction:
282 * @pad: the sink #GstPad that performed the chain.
283 * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
284 * @parent is guaranteed to be not-NULL and remain valid during the
285 * execution of this function.
286 * @list: the #GstBufferList that is chained, not %NULL.
288 * A function that will be called on sinkpads when chaining buffer lists.
289 * The function typically processes the data contained in the buffer list and
290 * either consumes the data or passes it on to the internally linked pad(s).
292 * The implementer of this function receives a refcount to @list and
293 * should gst_buffer_list_unref() when the list is no longer needed.
295 * When a chainlist function detects an error in the data stream, it must
296 * post an error on the bus and return an appropriate #GstFlowReturn value.
298 * Returns: #GST_FLOW_OK for success
300 typedef GstFlowReturn (*GstPadChainListFunction) (GstPad *pad, GstObject *parent,
301 GstBufferList *list);
304 * GstPadGetRangeFunction:
305 * @pad: the src #GstPad to perform the getrange on.
306 * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
307 * @parent is guaranteed to be not-NULL and remain valid during the
308 * execution of this function.
309 * @offset: the offset of the range
310 * @length: the length of the range
311 * @buffer: a memory location to hold the result buffer, cannot be NULL.
313 * This function will be called on source pads when a peer element
314 * request a buffer at the specified @offset and @length. If this function
315 * returns #GST_FLOW_OK, the result buffer will be stored in @buffer. The
316 * contents of @buffer is invalid for any other return value.
318 * This function is installed on a source pad with
319 * gst_pad_set_getrange_function() and can only be called on source pads after
320 * they are successfully activated with gst_pad_activate_pull().
322 * @offset and @length are always given in byte units. @offset must normally be a value
323 * between 0 and the length in bytes of the data available on @pad. The
324 * length (duration in bytes) can be retrieved with a #GST_QUERY_DURATION or with a
325 * #GST_QUERY_SEEKING.
327 * Any @offset larger or equal than the length will make the function return
328 * #GST_FLOW_UNEXPECTED, which corresponds to EOS. In this case @buffer does not
329 * contain a valid buffer.
331 * The buffer size of @buffer will only be smaller than @length when @offset is
332 * near the end of the stream. In all other cases, the size of @buffer must be
333 * exactly the requested size.
335 * It is allowed to call this function with a 0 @length and valid @offset, in
336 * which case @buffer will contain a 0-sized buffer and the function returns
339 * When this function is called with a -1 @offset, the sequentially next buffer
340 * of length @length in the stream is returned.
342 * When this function is called with a -1 @length, a buffer with a default
343 * optimal length is returned in @buffer. The length might depend on the value
346 * Returns: #GST_FLOW_OK for success and a valid buffer in @buffer. Any other
347 * return value leaves @buffer undefined.
349 typedef GstFlowReturn (*GstPadGetRangeFunction) (GstPad *pad, GstObject *parent,
350 guint64 offset, guint length,
354 * GstPadEventFunction:
355 * @pad: the #GstPad to handle the event.
356 * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
357 * @parent is guaranteed to be not-NULL and remain valid during the
358 * execution of this function.
359 * @event: the #GstEvent to handle.
361 * Function signature to handle an event for the pad.
363 * Returns: TRUE if the pad could handle the event.
365 typedef gboolean (*GstPadEventFunction) (GstPad *pad, GstObject *parent,
371 * GstPadIterIntLinkFunction:
372 * @pad: The #GstPad to query.
373 * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
374 * @parent is guaranteed to be not-NULL and remain valid during the
375 * execution of this function.
377 * The signature of the internal pad link iterator function.
379 * Returns: a new #GstIterator that will iterate over all pads that are
380 * linked to the given pad on the inside of the parent element.
382 * the caller must call gst_iterator_free() after usage.
386 typedef GstIterator* (*GstPadIterIntLinkFunction) (GstPad *pad, GstObject *parent);
388 /* generic query function */
390 * GstPadQueryFunction:
391 * @pad: the #GstPad to query.
392 * @parent: the parent of @pad. If the #GST_PAD_FLAG_NEED_PARENT flag is set,
393 * @parent is guaranteed to be not-NULL and remain valid during the
394 * execution of this function.
395 * @query: the #GstQuery object to execute
397 * The signature of the query function.
399 * Returns: TRUE if the query could be performed.
401 typedef gboolean (*GstPadQueryFunction) (GstPad *pad, GstObject *parent,
408 * @pad: the #GstPad that is linked.
409 * @peer: the peer #GstPad of the link
411 * Function signature to handle a new link on the pad.
413 * Returns: the result of the link with the specified peer.
415 typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstPad *peer);
417 * GstPadUnlinkFunction
418 * @pad: the #GstPad that is linked.
420 * Function signature to handle a unlinking the pad prom its peer.
422 typedef void (*GstPadUnlinkFunction) (GstPad *pad);
427 * GstPadForwardFunction:
428 * @pad: the #GstPad that is forwarded.
429 * @user_data: the gpointer to optional user data.
431 * A forward function is called for all internally linked pads, see
434 * Returns: TRUE if the dispatching procedure has to be stopped.
436 typedef gboolean (*GstPadForwardFunction) (GstPad *pad, gpointer user_data);
440 * @GST_PAD_PROBE_TYPE_INVALID: invalid probe type
441 * @GST_PAD_PROBE_TYPE_IDLE: probe idle pads and block
442 * @GST_PAD_PROBE_TYPE_BLOCK: probe and block pads
443 * @GST_PAD_PROBE_TYPE_BUFFER: probe buffers
444 * @GST_PAD_PROBE_TYPE_BUFFER_LIST: probe buffer lists
445 * @GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM: probe downstream events
446 * @GST_PAD_PROBE_TYPE_EVENT_UPSTREAM: probe upstream events
447 * @GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM: probe downstream queries
448 * @GST_PAD_PROBE_TYPE_QUERY_UPSTREAM: probe upstream queries
449 * @GST_PAD_PROBE_TYPE_PUSH: probe push
450 * @GST_PAD_PROBE_TYPE_PULL: probe pull
452 * The different probing types that can occur. When either one of
453 * @GST_PAD_PROBE_TYPE_IDLE or @GST_PAD_PROBE_TYPE_BLOCK is used, the probe will be a
458 GST_PAD_PROBE_TYPE_INVALID = 0,
459 /* flags to control blocking */
460 GST_PAD_PROBE_TYPE_IDLE = (1 << 0),
461 GST_PAD_PROBE_TYPE_BLOCK = (1 << 1),
462 /* flags to select datatypes */
463 GST_PAD_PROBE_TYPE_BUFFER = (1 << 4),
464 GST_PAD_PROBE_TYPE_BUFFER_LIST = (1 << 5),
465 GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM = (1 << 6),
466 GST_PAD_PROBE_TYPE_EVENT_UPSTREAM = (1 << 7),
467 GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM = (1 << 8),
468 GST_PAD_PROBE_TYPE_QUERY_UPSTREAM = (1 << 9),
469 /* flags to select scheduling mode */
470 GST_PAD_PROBE_TYPE_PUSH = (1 << 12),
471 GST_PAD_PROBE_TYPE_PULL = (1 << 13),
474 #define GST_PAD_PROBE_TYPE_BLOCKING (GST_PAD_PROBE_TYPE_IDLE | GST_PAD_PROBE_TYPE_BLOCK)
475 #define GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM (GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM)
476 #define GST_PAD_PROBE_TYPE_BLOCK_UPSTREAM (GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_UPSTREAM)
477 #define GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM (GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST | \
478 GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM)
479 #define GST_PAD_PROBE_TYPE_DATA_UPSTREAM (GST_PAD_PROBE_TYPE_EVENT_UPSTREAM)
480 #define GST_PAD_PROBE_TYPE_DATA_BOTH (GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM | \
481 GST_PAD_PROBE_TYPE_DATA_UPSTREAM)
482 #define GST_PAD_PROBE_TYPE_EVENT_BOTH (GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM | \
483 GST_PAD_PROBE_TYPE_EVENT_UPSTREAM)
484 #define GST_PAD_PROBE_TYPE_QUERY_BOTH (GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM | \
485 GST_PAD_PROBE_TYPE_QUERY_UPSTREAM)
486 #define GST_PAD_PROBE_TYPE_ALL_BOTH (GST_PAD_PROBE_TYPE_DATA_BOTH | \
487 GST_PAD_PROBE_TYPE_QUERY_BOTH)
488 #define GST_PAD_PROBE_TYPE_SCHEDULING (GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_PULL)
492 * @GST_PAD_PROBE_OK: normal probe return value
493 * @GST_PAD_PROBE_DROP: drop data in data probes
494 * @GST_PAD_PROBE_REMOVE: remove probe
495 * @GST_PAD_PROBE_PASS: pass the data item in the block probe and block on
498 * Different return values for the #GstPadProbeCallback.
504 GST_PAD_PROBE_REMOVE,
511 * @type: the current probe type
512 * @data: type specific data, check the @type field to know the datatype.
513 * This field can be NULL.
514 * @offset: offset of pull probe, this field is valid when @type contains
515 * #GST_PAD_PROBE_TYPE_PULL
516 * @size: size of pull probe, this field is valid when @type contains
517 * #GST_PAD_PROBE_TYPE_PULL
519 * Info passed in the #GstPadProbeCallback.
523 GstPadProbeType type;
528 gpointer _gst_reserved[GST_PADDING];
531 #define GST_PAD_PROBE_INFO_TYPE(d) ((d)->type)
532 #define GST_PAD_PROBE_INFO_DATA(d) ((d)->data)
534 #define GST_PAD_PROBE_INFO_BUFFER(d) GST_BUFFER_CAST(GST_PAD_PROBE_INFO_DATA(d))
535 #define GST_PAD_PROBE_INFO_BUFFER_LIST(d) GST_BUFFER_LIST_CAST(GST_PAD_PROBE_INFO_DATA(d))
536 #define GST_PAD_PROBE_INFO_EVENT(d) GST_EVENT_CAST(GST_PAD_PROBE_INFO_DATA(d))
537 #define GST_PAD_PROBE_INFO_QUERY(d) GST_QUERY_CAST(GST_PAD_PROBE_INFO_DATA(d))
539 #define GST_PAD_PROBE_INFO_OFFSET(d) ((d)->offset)
540 #define GST_PAD_PROBE_INFO_SIZE(d) ((d)->size)
543 * GstPadProbeCallback
544 * @pad: the #GstPad that is blocked
545 * @info: #GstPadProbeInfo
546 * @user_data: the gpointer to optional user data.
548 * Callback used by gst_pad_add_probe(). Gets called to notify about the current
551 * The callback is allowed to modify the data pointer in @info.
553 typedef GstPadProbeReturn (*GstPadProbeCallback) (GstPad *pad, GstPadProbeInfo *info,
557 * GstPadStickyEventsForeachFunction:
559 * @event: the sticky #GstEvent.
560 * @user_data: the #gpointer to optional user data.
562 * Callback used by gst_pad_sticky_events_foreach().
564 * Returns: GST_FLOW_OK if the iteration should continue
566 typedef GstFlowReturn (*GstPadStickyEventsForeachFunction) (GstPad *pad, GstEvent *event,
571 * @GST_PAD_FLAG_BLOCKED: is dataflow on a pad blocked
572 * @GST_PAD_FLAG_FLUSHING: is pad refusing buffers
573 * @GST_PAD_FLAG_BLOCKING: is pad currently blocking on a buffer or event
574 * @GST_PAD_FLAG_NEED_RECONFIGURE: the pad should be reconfigured/renegotiated.
575 * The flag has to be unset manually after
576 * reconfiguration happened.
578 * @GST_PAD_FLAG_NEED_EVENTS: the pad has pending events
579 * @GST_PAD_FLAG_FIXED_CAPS: the pad is using fixed caps this means that once the
580 * caps are set on the pad, the caps query function only
581 * returns those caps.
582 * @GST_PAD_FLAG_PROXY_CAPS: the default event and query handler will forward
583 * all events and queries to the internally linked pads
584 * instead of discarding them.
585 * @GST_PAD_FLAG_NEED_PARENT: ensure that there is a parent object before calling
586 * into the pad callbacks.
587 * @GST_PAD_FLAG_LAST: offset to define more flags
592 GST_PAD_FLAG_BLOCKED = (GST_OBJECT_FLAG_LAST << 0),
593 GST_PAD_FLAG_FLUSHING = (GST_OBJECT_FLAG_LAST << 1),
594 GST_PAD_FLAG_BLOCKING = (GST_OBJECT_FLAG_LAST << 2),
595 GST_PAD_FLAG_NEED_RECONFIGURE = (GST_OBJECT_FLAG_LAST << 3),
596 GST_PAD_FLAG_NEED_EVENTS = (GST_OBJECT_FLAG_LAST << 4),
597 GST_PAD_FLAG_FIXED_CAPS = (GST_OBJECT_FLAG_LAST << 5),
598 GST_PAD_FLAG_PROXY_CAPS = (GST_OBJECT_FLAG_LAST << 6),
599 GST_PAD_FLAG_NEED_PARENT = (GST_OBJECT_FLAG_LAST << 7),
601 GST_PAD_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 16)
606 * @element_private: private data owned by the parent element
607 * @padtemplate: padtemplate for this pad
608 * @direction: the direction of the pad, cannot change after creating
610 * @stream_rec_lock: recursive stream lock of the pad, used to protect
611 * the data used in streaming.
612 * @task: task for this pad if the pad is actively driving dataflow.
613 * @block_cond: conditional to signal pad block
614 * @probes: installed probes
615 * @mode: current activation mode of the pad
616 * @activatefunc: pad activation function
617 * @activatepushfunc: function to activate/deactivate pad in push mode
618 * @activatepullfunc: function to activate/deactivate pad in pull mode
619 * @peer: the pad this pad is linked to
620 * @linkfunc: function called when pad is linked
621 * @unlinkfunc: function called when pad is unlinked
622 * @chainfunc: function to chain buffer to pad
623 * @chainlistfunc: function to chain a list of buffers to pad
624 * @getrangefunc: function to get a range of data from a pad
625 * @eventfunc: function to send an event to a pad
626 * @offset: the pad offset
627 * @queryfunc: perform a query on the pad
628 * @iterintlinkfunc: get the internal links iterator of this pad
630 * The #GstPad structure. Use the functions to update the variables.
636 gpointer element_private;
638 GstPadTemplate *padtemplate;
640 GstPadDirection direction;
642 /*< public >*/ /* with STREAM_LOCK */
643 /* streaming rec_lock */
644 GStaticRecMutex stream_rec_lock;
647 /*< public >*/ /* with LOCK */
648 /* block cond, mutex is from the object */
653 GstPadActivateFunction activatefunc;
654 GstPadActivateModeFunction activatepushfunc;
655 GstPadActivateModeFunction activatepullfunc;
659 GstPadLinkFunction linkfunc;
660 GstPadUnlinkFunction unlinkfunc;
662 /* data transport functions */
663 GstPadChainFunction chainfunc;
664 GstPadChainListFunction chainlistfunc;
665 GstPadGetRangeFunction getrangefunc;
666 GstPadEventFunction eventfunc;
671 /* generic query method */
672 GstPadQueryFunction queryfunc;
675 GstPadIterIntLinkFunction iterintlinkfunc;
678 /* counts number of probes attached. */
684 gpointer _gst_reserved[GST_PADDING];
687 struct _GstPadClass {
688 GstObjectClass parent_class;
690 /* signal callbacks */
691 void (*linked) (GstPad *pad, GstPad *peer);
692 void (*unlinked) (GstPad *pad, GstPad *peer);
695 gpointer _gst_reserved[GST_PADDING];
699 /***** helper macros *****/
701 #define GST_PAD_NAME(pad) (GST_OBJECT_NAME(pad))
702 #define GST_PAD_PARENT(pad) (GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad)))
703 #define GST_PAD_ELEMENT_PRIVATE(pad) (GST_PAD_CAST(pad)->element_private)
704 #define GST_PAD_PAD_TEMPLATE(pad) (GST_PAD_CAST(pad)->padtemplate)
705 #define GST_PAD_DIRECTION(pad) (GST_PAD_CAST(pad)->direction)
706 #define GST_PAD_TASK(pad) (GST_PAD_CAST(pad)->task)
707 #define GST_PAD_MODE(pad) (GST_PAD_CAST(pad)->mode)
709 #define GST_PAD_ACTIVATEFUNC(pad) (GST_PAD_CAST(pad)->activatefunc)
710 #define GST_PAD_ACTIVATEPUSHFUNC(pad) (GST_PAD_CAST(pad)->activatepushfunc)
711 #define GST_PAD_ACTIVATEPULLFUNC(pad) (GST_PAD_CAST(pad)->activatepullfunc)
712 #define GST_PAD_CHAINFUNC(pad) (GST_PAD_CAST(pad)->chainfunc)
713 #define GST_PAD_CHAINLISTFUNC(pad) (GST_PAD_CAST(pad)->chainlistfunc)
714 #define GST_PAD_GETRANGEFUNC(pad) (GST_PAD_CAST(pad)->getrangefunc)
715 #define GST_PAD_EVENTFUNC(pad) (GST_PAD_CAST(pad)->eventfunc)
716 #define GST_PAD_QUERYFUNC(pad) (GST_PAD_CAST(pad)->queryfunc)
717 #define GST_PAD_ITERINTLINKFUNC(pad) (GST_PAD_CAST(pad)->iterintlinkfunc)
719 #define GST_PAD_PEER(pad) (GST_PAD_CAST(pad)->peer)
720 #define GST_PAD_LINKFUNC(pad) (GST_PAD_CAST(pad)->linkfunc)
721 #define GST_PAD_UNLINKFUNC(pad) (GST_PAD_CAST(pad)->unlinkfunc)
723 #define GST_PAD_IS_SRC(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
724 #define GST_PAD_IS_SINK(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
726 #define GST_PAD_IS_LINKED(pad) (GST_PAD_PEER(pad) != NULL)
728 #define GST_PAD_IS_ACTIVE(pad) (GST_PAD_MODE(pad) != GST_PAD_MODE_NONE)
730 #define GST_PAD_IS_BLOCKED(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKED))
731 #define GST_PAD_IS_BLOCKING(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKING))
733 #define GST_PAD_IS_FLUSHING(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FLUSHING))
734 #define GST_PAD_SET_FLUSHING(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_FLUSHING))
735 #define GST_PAD_UNSET_FLUSHING(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_FLUSHING))
737 #define GST_PAD_NEEDS_RECONFIGURE(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_NEED_RECONFIGURE))
738 #define GST_PAD_NEEDS_EVENTS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_NEED_EVENTS))
739 #define GST_PAD_IS_FIXED_CAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FIXED_CAPS))
740 #define GST_PAD_NEEDS_PARENT(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_NEED_PARENT))
742 #define GST_PAD_IS_PROXY_CAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_PROXY_CAPS))
743 #define GST_PAD_SET_PROXY_CAPS(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_PROXY_CAPS))
744 #define GST_PAD_UNSET_PROXY_CAPS(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_PROXY_CAPS))
747 * GST_PAD_GET_STREAM_LOCK:
750 * Get the stream lock of @pad. The stream lock is protecting the
751 * resources used in the data processing functions of @pad.
753 #define GST_PAD_GET_STREAM_LOCK(pad) (&(GST_PAD_CAST(pad)->stream_rec_lock))
755 * GST_PAD_STREAM_LOCK:
758 * Lock the stream lock of @pad.
760 #define GST_PAD_STREAM_LOCK(pad) (g_static_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad)))
762 * GST_PAD_STREAM_TRYLOCK:
765 * Try to Lock the stream lock of the pad, return TRUE if the lock could be
768 #define GST_PAD_STREAM_TRYLOCK(pad) (g_static_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad)))
770 * GST_PAD_STREAM_UNLOCK:
773 * Unlock the stream lock of @pad.
775 #define GST_PAD_STREAM_UNLOCK(pad) (g_static_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad)))
777 #define GST_PAD_BLOCK_GET_COND(pad) (GST_PAD_CAST(pad)->block_cond)
778 #define GST_PAD_BLOCK_WAIT(pad) (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad)))
779 #define GST_PAD_BLOCK_SIGNAL(pad) (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad)))
780 #define GST_PAD_BLOCK_BROADCAST(pad) (g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad)))
782 GType gst_pad_get_type (void);
785 GstPad* gst_pad_new (const gchar *name, GstPadDirection direction);
786 GstPad* gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name);
787 GstPad* gst_pad_new_from_static_template (GstStaticPadTemplate *templ, const gchar *name);
792 * @pad: the pad to get the name from
794 * Get a copy of the name of the pad. g_free() after usage.
798 #define gst_pad_get_name(pad) gst_object_get_name (GST_OBJECT_CAST (pad))
800 * gst_pad_get_parent:
801 * @pad: the pad to get the parent of
803 * Get the parent of @pad. This function increases the refcount
804 * of the parent object so you should gst_object_unref() it after usage.
805 * Can return NULL if the pad did not have a parent.
809 #define gst_pad_get_parent(pad) gst_object_get_parent (GST_OBJECT_CAST (pad))
811 GstPadDirection gst_pad_get_direction (GstPad *pad);
813 gboolean gst_pad_set_active (GstPad *pad, gboolean active);
814 gboolean gst_pad_is_active (GstPad *pad);
815 gboolean gst_pad_activate_pull (GstPad *pad, gboolean active);
816 gboolean gst_pad_activate_push (GstPad *pad, gboolean active);
818 gulong gst_pad_add_probe (GstPad *pad,
819 GstPadProbeType mask,
820 GstPadProbeCallback callback,
822 GDestroyNotify destroy_data);
823 void gst_pad_remove_probe (GstPad *pad, gulong id);
825 gboolean gst_pad_is_blocked (GstPad *pad);
826 gboolean gst_pad_is_blocking (GstPad *pad);
828 void gst_pad_mark_reconfigure (GstPad *pad);
829 gboolean gst_pad_check_reconfigure (GstPad *pad);
831 void gst_pad_set_element_private (GstPad *pad, gpointer priv);
832 gpointer gst_pad_get_element_private (GstPad *pad);
834 GstPadTemplate* gst_pad_get_pad_template (GstPad *pad);
836 GstEvent* gst_pad_get_sticky_event (GstPad *pad, GstEventType event_type);
837 GstFlowReturn gst_pad_sticky_events_foreach (GstPad *pad, GstPadStickyEventsForeachFunction foreach_func, gpointer user_data);
839 /* data passing setup functions */
840 void gst_pad_set_activate_function (GstPad *pad, GstPadActivateFunction activate);
841 void gst_pad_set_activatepull_function (GstPad *pad, GstPadActivateModeFunction activatepull);
842 void gst_pad_set_activatepush_function (GstPad *pad, GstPadActivateModeFunction activatepush);
843 void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
844 void gst_pad_set_chain_list_function (GstPad *pad, GstPadChainListFunction chainlist);
845 void gst_pad_set_getrange_function (GstPad *pad, GstPadGetRangeFunction get);
846 void gst_pad_set_event_function (GstPad *pad, GstPadEventFunction event);
849 void gst_pad_set_link_function (GstPad *pad, GstPadLinkFunction link);
850 void gst_pad_set_unlink_function (GstPad *pad, GstPadUnlinkFunction unlink);
852 gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad);
853 GstPadLinkReturn gst_pad_link (GstPad *srcpad, GstPad *sinkpad);
854 GstPadLinkReturn gst_pad_link_full (GstPad *srcpad, GstPad *sinkpad, GstPadLinkCheck flags);
855 gboolean gst_pad_unlink (GstPad *srcpad, GstPad *sinkpad);
856 gboolean gst_pad_is_linked (GstPad *pad);
858 GstPad* gst_pad_get_peer (GstPad *pad);
860 GstCaps* gst_pad_get_pad_template_caps (GstPad *pad);
862 /* capsnego function for linked/unlinked pads */
863 GstCaps * gst_pad_get_current_caps (GstPad * pad);
864 gboolean gst_pad_has_current_caps (GstPad * pad);
865 gboolean gst_pad_set_caps (GstPad * pad, GstCaps *caps);
867 /* capsnego for linked pads */
868 GstCaps * gst_pad_get_allowed_caps (GstPad * pad);
871 gint64 gst_pad_get_offset (GstPad *pad);
872 void gst_pad_set_offset (GstPad *pad, gint64 offset);
874 /* data passing functions to peer */
875 GstFlowReturn gst_pad_push (GstPad *pad, GstBuffer *buffer);
876 GstFlowReturn gst_pad_push_list (GstPad *pad, GstBufferList *list);
877 GstFlowReturn gst_pad_pull_range (GstPad *pad, guint64 offset, guint size,
879 gboolean gst_pad_push_event (GstPad *pad, GstEvent *event);
880 gboolean gst_pad_event_default (GstPad *pad, GstObject *parent,
883 /* data passing functions on pad */
884 GstFlowReturn gst_pad_chain (GstPad *pad, GstBuffer *buffer);
885 GstFlowReturn gst_pad_chain_list (GstPad *pad, GstBufferList *list);
886 GstFlowReturn gst_pad_get_range (GstPad *pad, guint64 offset, guint size,
888 gboolean gst_pad_send_event (GstPad *pad, GstEvent *event);
891 gboolean gst_pad_start_task (GstPad *pad, GstTaskFunction func,
893 gboolean gst_pad_pause_task (GstPad *pad);
894 gboolean gst_pad_stop_task (GstPad *pad);
897 void gst_pad_set_iterate_internal_links_function (GstPad * pad,
898 GstPadIterIntLinkFunction iterintlink);
899 GstIterator * gst_pad_iterate_internal_links (GstPad * pad);
900 GstIterator * gst_pad_iterate_internal_links_default (GstPad * pad, GstObject *parent);
903 /* generic query function */
904 gboolean gst_pad_query (GstPad *pad, GstQuery *query);
905 gboolean gst_pad_peer_query (GstPad *pad, GstQuery *query);
906 void gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query);
907 gboolean gst_pad_query_default (GstPad *pad, GstObject *parent,
910 /* misc helper functions */
911 gboolean gst_pad_forward (GstPad *pad, GstPadForwardFunction forward,
916 #endif /* __GST_PAD_H__ */