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_get_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))
215 * GstPadActivateMode:
216 * @GST_PAD_ACTIVATE_NONE: Pad will not handle dataflow
217 * @GST_PAD_ACTIVATE_PUSH: Pad handles dataflow in downstream push mode
218 * @GST_PAD_ACTIVATE_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 GstPadActivateMode defines if the
222 * pad operates in push or pull mode.
225 GST_PAD_ACTIVATE_NONE,
226 GST_PAD_ACTIVATE_PUSH,
227 GST_PAD_ACTIVATE_PULL
228 } GstPadActivateMode;
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);
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, gboolean active);
257 * GstPadChainFunction:
258 * @pad: the sink #GstPad that performed the chain.
259 * @buffer: the #GstBuffer that is chained, not %NULL.
261 * A function that will be called on sinkpads when chaining buffers.
262 * The function typically processes the data contained in the buffer and
263 * either consumes the data or passes it on to the internally linked pad(s).
265 * The implementer of this function receives a refcount to @buffer and should
266 * gst_buffer_unref() when the buffer is no longer needed.
268 * When a chain function detects an error in the data stream, it must post an
269 * error on the bus and return an appropriate #GstFlowReturn value.
271 * Returns: #GST_FLOW_OK for success
273 typedef GstFlowReturn (*GstPadChainFunction) (GstPad *pad, GstBuffer *buffer);
276 * GstPadChainListFunction:
277 * @pad: the sink #GstPad that performed the chain.
278 * @list: the #GstBufferList that is chained, not %NULL.
280 * A function that will be called on sinkpads when chaining buffer lists.
281 * The function typically processes the data contained in the buffer list and
282 * either consumes the data or passes it on to the internally linked pad(s).
284 * The implementer of this function receives a refcount to @list and
285 * should gst_buffer_list_unref() when the list is no longer needed.
287 * When a chainlist function detects an error in the data stream, it must
288 * post an error on the bus and return an appropriate #GstFlowReturn value.
290 * Returns: #GST_FLOW_OK for success
292 typedef GstFlowReturn (*GstPadChainListFunction) (GstPad *pad, GstBufferList *list);
295 * GstPadGetRangeFunction:
296 * @pad: the src #GstPad to perform the getrange on.
297 * @offset: the offset of the range
298 * @length: the length of the range
299 * @buffer: a memory location to hold the result buffer, cannot be NULL.
301 * This function will be called on source pads when a peer element
302 * request a buffer at the specified @offset and @length. If this function
303 * returns #GST_FLOW_OK, the result buffer will be stored in @buffer. The
304 * contents of @buffer is invalid for any other return value.
306 * This function is installed on a source pad with
307 * gst_pad_set_getrange_function() and can only be called on source pads after
308 * they are successfully activated with gst_pad_activate_pull().
310 * @offset and @length are always given in byte units. @offset must normally be a value
311 * between 0 and the length in bytes of the data available on @pad. The
312 * length (duration in bytes) can be retrieved with a #GST_QUERY_DURATION or with a
313 * #GST_QUERY_SEEKING.
315 * Any @offset larger or equal than the length will make the function return
316 * #GST_FLOW_UNEXPECTED, which corresponds to EOS. In this case @buffer does not
317 * contain a valid buffer.
319 * The buffer size of @buffer will only be smaller than @length when @offset is
320 * near the end of the stream. In all other cases, the size of @buffer must be
321 * exactly the requested size.
323 * It is allowed to call this function with a 0 @length and valid @offset, in
324 * which case @buffer will contain a 0-sized buffer and the function returns
327 * When this function is called with a -1 @offset, the sequentially next buffer
328 * of length @length in the stream is returned.
330 * When this function is called with a -1 @length, a buffer with a default
331 * optimal length is returned in @buffer. The length might depend on the value
334 * Returns: #GST_FLOW_OK for success and a valid buffer in @buffer. Any other
335 * return value leaves @buffer undefined.
337 typedef GstFlowReturn (*GstPadGetRangeFunction) (GstPad *pad, guint64 offset,
338 guint length, GstBuffer **buffer);
341 * GstPadEventFunction:
342 * @pad: the #GstPad to handle the event.
343 * @event: the #GstEvent to handle.
345 * Function signature to handle an event for the pad.
347 * Returns: TRUE if the pad could handle the event.
349 typedef gboolean (*GstPadEventFunction) (GstPad *pad, GstEvent *event);
354 * GstPadIterIntLinkFunction:
355 * @pad: The #GstPad to query.
357 * The signature of the internal pad link iterator function.
359 * Returns: a new #GstIterator that will iterate over all pads that are
360 * linked to the given pad on the inside of the parent element.
362 * the caller must call gst_iterator_free() after usage.
366 typedef GstIterator* (*GstPadIterIntLinkFunction) (GstPad *pad);
368 /* generic query function */
370 * GstPadQueryTypeFunction:
371 * @pad: a #GstPad to query
373 * The signature of the query types function.
375 * Returns: a constant array of query types
377 typedef const GstQueryType* (*GstPadQueryTypeFunction) (GstPad *pad);
380 * GstPadQueryFunction:
381 * @pad: the #GstPad to query.
382 * @query: the #GstQuery object to execute
384 * The signature of the query function.
386 * Returns: TRUE if the query could be performed.
388 typedef gboolean (*GstPadQueryFunction) (GstPad *pad, GstQuery *query);
394 * @pad: the #GstPad that is linked.
395 * @peer: the peer #GstPad of the link
397 * Function signature to handle a new link on the pad.
399 * Returns: the result of the link with the specified peer.
401 typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstPad *peer);
403 * GstPadUnlinkFunction
404 * @pad: the #GstPad that is linked.
406 * Function signature to handle a unlinking the pad prom its peer.
408 typedef void (*GstPadUnlinkFunction) (GstPad *pad);
413 * GstPadGetCapsFunction:
414 * @pad: the #GstPad to get the capabilities of.
415 * @filter: filter #GstCaps.
417 * When called on sinkpads @filter contains the caps that
418 * upstream could produce in the order preferred by upstream. When
419 * called on srcpads @filter contains the caps accepted by
420 * downstream in the preffered order. @filter might be %NULL but if
421 * it is not %NULL only a subset of @filter must be returned.
423 * Returns a copy of the capabilities of the specified pad. By default this
424 * function will return the pad template capabilities, but can optionally
425 * be overridden by elements.
427 * Returns: a newly allocated copy #GstCaps of the pad.
429 typedef GstCaps* (*GstPadGetCapsFunction) (GstPad *pad, GstCaps *filter);
432 * GstPadAcceptCapsFunction:
433 * @pad: the #GstPad to check
434 * @caps: the #GstCaps to check
436 * Check if @pad can accept @caps. By default this function will see if @caps
437 * intersect with the result from gst_pad_get_caps() by can be overridden to
438 * perform extra checks.
440 * Returns: TRUE if the caps can be accepted by the pad.
442 typedef gboolean (*GstPadAcceptCapsFunction) (GstPad *pad, GstCaps *caps);
444 * GstPadFixateCapsFunction:
446 * @caps: the #GstCaps to fixate
448 * Given possibly unfixed caps @caps, let @pad use its default preferred
449 * format to make a fixed caps. @caps should be writable. By default this
450 * function will pick the first value of any ranges or lists in the caps but
451 * elements can override this function to perform other behaviour.
453 typedef void (*GstPadFixateCapsFunction) (GstPad *pad, GstCaps *caps);
457 * GstPadForwardFunction:
458 * @pad: the #GstPad that is forwarded.
459 * @user_data: the gpointer to optional user data.
461 * A forward function is called for all internally linked pads, see
464 * Returns: TRUE if the dispatching procedure has to be stopped.
466 typedef gboolean (*GstPadForwardFunction) (GstPad *pad, gpointer user_data);
470 * @GST_PAD_PROBE_TYPE_INVALID: invalid probe type
471 * @GST_PAD_PROBE_TYPE_IDLE: probe idle pads and block
472 * @GST_PAD_PROBE_TYPE_BLOCK: probe and block pads
473 * @GST_PAD_PROBE_TYPE_BUFFER: probe buffers
474 * @GST_PAD_PROBE_TYPE_BUFFER_LIST: probe buffer lists
475 * @GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM: probe downstream events
476 * @GST_PAD_PROBE_TYPE_EVENT_UPSTREAM: probe upstream events
477 * @GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM: probe downstream queries
478 * @GST_PAD_PROBE_TYPE_QUERY_UPSTREAM: probe upstream queries
479 * @GST_PAD_PROBE_TYPE_PUSH: probe push
480 * @GST_PAD_PROBE_TYPE_PULL: probe pull
482 * The different probing types that can occur. When either one of
483 * @GST_PAD_PROBE_TYPE_IDLE or @GST_PAD_PROBE_TYPE_BLOCK is used, the probe will be a
488 GST_PAD_PROBE_TYPE_INVALID = 0,
489 /* flags to control blocking */
490 GST_PAD_PROBE_TYPE_IDLE = (1 << 0),
491 GST_PAD_PROBE_TYPE_BLOCK = (1 << 1),
492 /* flags to select datatypes */
493 GST_PAD_PROBE_TYPE_BUFFER = (1 << 4),
494 GST_PAD_PROBE_TYPE_BUFFER_LIST = (1 << 5),
495 GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM = (1 << 6),
496 GST_PAD_PROBE_TYPE_EVENT_UPSTREAM = (1 << 7),
497 GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM = (1 << 8),
498 GST_PAD_PROBE_TYPE_QUERY_UPSTREAM = (1 << 9),
499 /* flags to select scheduling mode */
500 GST_PAD_PROBE_TYPE_PUSH = (1 << 12),
501 GST_PAD_PROBE_TYPE_PULL = (1 << 13),
504 #define GST_PAD_PROBE_TYPE_BLOCKING (GST_PAD_PROBE_TYPE_IDLE | GST_PAD_PROBE_TYPE_BLOCK)
505 #define GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM (GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM)
506 #define GST_PAD_PROBE_TYPE_BLOCK_UPSTREAM (GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_DATA_UPSTREAM)
507 #define GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM (GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST | \
508 GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM)
509 #define GST_PAD_PROBE_TYPE_DATA_UPSTREAM (GST_PAD_PROBE_TYPE_EVENT_UPSTREAM)
510 #define GST_PAD_PROBE_TYPE_DATA_BOTH (GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM | \
511 GST_PAD_PROBE_TYPE_DATA_UPSTREAM)
512 #define GST_PAD_PROBE_TYPE_EVENT_BOTH (GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM | \
513 GST_PAD_PROBE_TYPE_EVENT_UPSTREAM)
514 #define GST_PAD_PROBE_TYPE_SCHEDULING (GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_PULL)
518 * @GST_PAD_PROBE_OK: normal probe return value
519 * @GST_PAD_PROBE_DROP: drop data in data probes
520 * @GST_PAD_PROBE_REMOVE: remove probe
521 * @GST_PAD_PROBE_PASS: pass the data item in the block probe and block on
524 * Different return values for the #GstPadProbeCallback.
530 GST_PAD_PROBE_REMOVE,
537 * @type: the current probe type
538 * @data: type specific data, check the @type field to know the datatype.
539 * This field can be NULL.
540 * @offset: offset of pull probe, this field is valid when @type contains
541 * #GST_PAD_PROBE_TYPE_PULL
542 * @size: size of pull probe, this field is valid when @type contains
543 * #GST_PAD_PROBE_TYPE_PULL
545 * Info passed in the #GstPadProbeCallback.
549 GstPadProbeType type;
555 #define GST_PAD_PROBE_INFO_TYPE(d) ((d)->type)
556 #define GST_PAD_PROBE_INFO_DATA(d) ((d)->data)
558 #define GST_PAD_PROBE_INFO_BUFFER(d) GST_BUFFER_CAST(GST_PAD_PROBE_INFO_DATA(d))
559 #define GST_PAD_PROBE_INFO_BUFFER_LIST(d) GST_BUFFER_LIST_CAST(GST_PAD_PROBE_INFO_DATA(d))
560 #define GST_PAD_PROBE_INFO_EVENT(d) GST_EVENT_CAST(GST_PAD_PROBE_INFO_DATA(d))
561 #define GST_PAD_PROBE_INFO_QUERY(d) GST_QUERY_CAST(GST_PAD_PROBE_INFO_DATA(d))
563 #define GST_PAD_PROBE_INFO_OFFSET(d) ((d)->offset)
564 #define GST_PAD_PROBE_INFO_SIZE(d) ((d)->size)
567 * GstPadProbeCallback
568 * @pad: the #GstPad that is blocked
569 * @info: #GstPadProbeInfo
570 * @user_data: the gpointer to optional user data.
572 * Callback used by gst_pad_add_probe(). Gets called to notify about the current
575 * The callback is allowed to modify the data pointer in @info.
577 typedef GstPadProbeReturn (*GstPadProbeCallback) (GstPad *pad, GstPadProbeInfo *info,
581 * GstPadStickyEventsForeachFunction:
583 * @event: the sticky #GstEvent.
584 * @user_data: the #gpointer to optional user data.
586 * Callback used by gst_pad_sticky_events_foreach().
588 * Returns: GST_FLOW_OK if the iteration should continue
590 typedef GstFlowReturn (*GstPadStickyEventsForeachFunction) (GstPad *pad, GstEvent *event,
595 * @GST_PAD_BLOCKED: is dataflow on a pad blocked
596 * @GST_PAD_FLUSHING: is pad refusing buffers
597 * @GST_PAD_IN_GETCAPS: GstPadGetCapsFunction() is running now
598 * @GST_PAD_BLOCKING: is pad currently blocking on a buffer or event
599 * @GST_PAD_NEED_RECONFIGURE: the pad should be reconfigured/renegotiated.
600 * The flag has to be unset manually after
601 * reconfiguration happened.
603 * @GST_PAD_NEED_EVENTS: the pad has pending events
604 * @GST_PAD_FIXED_CAPS: the pad is using fixed caps this means that once the
605 * caps are set on the pad, the getcaps function only
606 * returns those caps.
607 * @GST_PAD_FLAG_LAST: offset to define more flags
612 GST_PAD_BLOCKED = (GST_OBJECT_FLAG_LAST << 0),
613 GST_PAD_FLUSHING = (GST_OBJECT_FLAG_LAST << 1),
614 GST_PAD_IN_GETCAPS = (GST_OBJECT_FLAG_LAST << 2),
615 GST_PAD_BLOCKING = (GST_OBJECT_FLAG_LAST << 4),
616 GST_PAD_NEED_RECONFIGURE = (GST_OBJECT_FLAG_LAST << 5),
617 GST_PAD_NEED_EVENTS = (GST_OBJECT_FLAG_LAST << 6),
618 GST_PAD_FIXED_CAPS = (GST_OBJECT_FLAG_LAST << 7),
620 GST_PAD_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 16)
625 * @element_private: private data owned by the parent element
626 * @padtemplate: padtemplate for this pad
627 * @direction: the direction of the pad, cannot change after creating
629 * @stream_rec_lock: recursive stream lock of the pad, used to protect
630 * the data used in streaming.
631 * @task: task for this pad if the pad is actively driving dataflow.
632 * @block_cond: conditional to signal pad block
633 * @probes: installed probes
634 * @getcapsfunc: function to get caps of the pad
635 * @acceptcapsfunc: function to check if pad can accept caps
636 * @fixatecapsfunc: function to fixate caps
637 * @mode: current activation mode of the pad
638 * @activatefunc: pad activation function
639 * @activatepushfunc: function to activate/deactivate pad in push mode
640 * @activatepullfunc: function to activate/deactivate pad in pull mode
641 * @peer: the pad this pad is linked to
642 * @linkfunc: function called when pad is linked
643 * @unlinkfunc: function called when pad is unlinked
644 * @chainfunc: function to chain buffer to pad
645 * @chainlistfunc: function to chain a list of buffers to pad
646 * @getrangefunc: function to get a range of data from a pad
647 * @eventfunc: function to send an event to a pad
648 * @offset: the pad offset
649 * @querytypefunc: get list of supported queries
650 * @queryfunc: perform a query on the pad
651 * @iterintlinkfunc: get the internal links iterator of this pad
653 * The #GstPad structure. Use the functions to update the variables.
659 gpointer element_private;
661 GstPadTemplate *padtemplate;
663 GstPadDirection direction;
665 /*< public >*/ /* with STREAM_LOCK */
666 /* streaming rec_lock */
667 GStaticRecMutex stream_rec_lock;
670 /*< public >*/ /* with LOCK */
671 /* block cond, mutex is from the object */
675 /* the pad capabilities */
676 GstPadGetCapsFunction getcapsfunc;
677 GstPadAcceptCapsFunction acceptcapsfunc;
678 GstPadFixateCapsFunction fixatecapsfunc;
680 GstPadActivateMode mode;
681 GstPadActivateFunction activatefunc;
682 GstPadActivateModeFunction activatepushfunc;
683 GstPadActivateModeFunction activatepullfunc;
687 GstPadLinkFunction linkfunc;
688 GstPadUnlinkFunction unlinkfunc;
690 /* data transport functions */
691 GstPadChainFunction chainfunc;
692 GstPadChainListFunction chainlistfunc;
693 GstPadGetRangeFunction getrangefunc;
694 GstPadEventFunction eventfunc;
699 /* generic query method */
700 GstPadQueryTypeFunction querytypefunc;
701 GstPadQueryFunction queryfunc;
704 GstPadIterIntLinkFunction iterintlinkfunc;
707 /* counts number of probes attached. */
713 gpointer _gst_reserved[GST_PADDING];
716 struct _GstPadClass {
717 GstObjectClass parent_class;
719 /* signal callbacks */
720 void (*linked) (GstPad *pad, GstPad *peer);
721 void (*unlinked) (GstPad *pad, GstPad *peer);
724 gpointer _gst_reserved[GST_PADDING];
728 /***** helper macros *****/
730 #define GST_PAD_NAME(pad) (GST_OBJECT_NAME(pad))
731 #define GST_PAD_PARENT(pad) (GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad)))
732 #define GST_PAD_ELEMENT_PRIVATE(pad) (GST_PAD_CAST(pad)->element_private)
733 #define GST_PAD_PAD_TEMPLATE(pad) (GST_PAD_CAST(pad)->padtemplate)
734 #define GST_PAD_DIRECTION(pad) (GST_PAD_CAST(pad)->direction)
735 #define GST_PAD_TASK(pad) (GST_PAD_CAST(pad)->task)
736 #define GST_PAD_ACTIVATE_MODE(pad) (GST_PAD_CAST(pad)->mode)
738 #define GST_PAD_ACTIVATEFUNC(pad) (GST_PAD_CAST(pad)->activatefunc)
739 #define GST_PAD_ACTIVATEPUSHFUNC(pad) (GST_PAD_CAST(pad)->activatepushfunc)
740 #define GST_PAD_ACTIVATEPULLFUNC(pad) (GST_PAD_CAST(pad)->activatepullfunc)
741 #define GST_PAD_CHAINFUNC(pad) (GST_PAD_CAST(pad)->chainfunc)
742 #define GST_PAD_CHAINLISTFUNC(pad) (GST_PAD_CAST(pad)->chainlistfunc)
743 #define GST_PAD_GETRANGEFUNC(pad) (GST_PAD_CAST(pad)->getrangefunc)
744 #define GST_PAD_EVENTFUNC(pad) (GST_PAD_CAST(pad)->eventfunc)
745 #define GST_PAD_QUERYTYPEFUNC(pad) (GST_PAD_CAST(pad)->querytypefunc)
746 #define GST_PAD_QUERYFUNC(pad) (GST_PAD_CAST(pad)->queryfunc)
747 #define GST_PAD_ITERINTLINKFUNC(pad) (GST_PAD_CAST(pad)->iterintlinkfunc)
749 #define GST_PAD_PEER(pad) (GST_PAD_CAST(pad)->peer)
750 #define GST_PAD_LINKFUNC(pad) (GST_PAD_CAST(pad)->linkfunc)
751 #define GST_PAD_UNLINKFUNC(pad) (GST_PAD_CAST(pad)->unlinkfunc)
753 #define GST_PAD_GETCAPSFUNC(pad) (GST_PAD_CAST(pad)->getcapsfunc)
754 #define GST_PAD_ACCEPTCAPSFUNC(pad) (GST_PAD_CAST(pad)->acceptcapsfunc)
755 #define GST_PAD_FIXATECAPSFUNC(pad) (GST_PAD_CAST(pad)->fixatecapsfunc)
757 #define GST_PAD_IS_SRC(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
758 #define GST_PAD_IS_SINK(pad) (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
760 #define GST_PAD_IS_LINKED(pad) (GST_PAD_PEER(pad) != NULL)
762 #define GST_PAD_IS_ACTIVE(pad) (GST_PAD_ACTIVATE_MODE(pad) != GST_PAD_ACTIVATE_NONE)
764 #define GST_PAD_IS_BLOCKED(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED))
765 #define GST_PAD_IS_BLOCKING(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKING))
766 #define GST_PAD_IS_FLUSHING(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING))
767 #define GST_PAD_IS_IN_GETCAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS))
768 #define GST_PAD_NEEDS_RECONFIGURE(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_NEED_RECONFIGURE))
769 #define GST_PAD_NEEDS_EVENTS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_NEED_EVENTS))
770 #define GST_PAD_IS_FIXED_CAPS(pad) (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FIXED_CAPS))
772 #define GST_PAD_SET_FLUSHING(pad) (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLUSHING))
773 #define GST_PAD_UNSET_FLUSHING(pad) (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLUSHING))
776 * GST_PAD_GET_STREAM_LOCK:
779 * Get the stream lock of @pad. The stream lock is protecting the
780 * resources used in the data processing functions of @pad.
782 #define GST_PAD_GET_STREAM_LOCK(pad) (&(GST_PAD_CAST(pad)->stream_rec_lock))
784 * GST_PAD_STREAM_LOCK:
787 * Lock the stream lock of @pad.
789 #define GST_PAD_STREAM_LOCK(pad) (g_static_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad)))
791 * GST_PAD_STREAM_TRYLOCK:
794 * Try to Lock the stream lock of the pad, return TRUE if the lock could be
797 #define GST_PAD_STREAM_TRYLOCK(pad) (g_static_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad)))
799 * GST_PAD_STREAM_UNLOCK:
802 * Unlock the stream lock of @pad.
804 #define GST_PAD_STREAM_UNLOCK(pad) (g_static_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad)))
806 #define GST_PAD_BLOCK_GET_COND(pad) (GST_PAD_CAST(pad)->block_cond)
807 #define GST_PAD_BLOCK_WAIT(pad) (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad)))
808 #define GST_PAD_BLOCK_SIGNAL(pad) (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad)))
809 #define GST_PAD_BLOCK_BROADCAST(pad) (g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad)))
811 GType gst_pad_get_type (void);
814 GstPad* gst_pad_new (const gchar *name, GstPadDirection direction);
815 GstPad* gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name);
816 GstPad* gst_pad_new_from_static_template (GstStaticPadTemplate *templ, const gchar *name);
821 * @pad: the pad to get the name from
823 * Get a copy of the name of the pad. g_free() after usage.
827 #define gst_pad_get_name(pad) gst_object_get_name (GST_OBJECT_CAST (pad))
829 * gst_pad_get_parent:
830 * @pad: the pad to get the parent of
832 * Get the parent of @pad. This function increases the refcount
833 * of the parent object so you should gst_object_unref() it after usage.
834 * Can return NULL if the pad did not have a parent.
838 #define gst_pad_get_parent(pad) gst_object_get_parent (GST_OBJECT_CAST (pad))
840 GstPadDirection gst_pad_get_direction (GstPad *pad);
842 gboolean gst_pad_set_active (GstPad *pad, gboolean active);
843 gboolean gst_pad_is_active (GstPad *pad);
844 gboolean gst_pad_activate_pull (GstPad *pad, gboolean active);
845 gboolean gst_pad_activate_push (GstPad *pad, gboolean active);
847 gulong gst_pad_add_probe (GstPad *pad,
848 GstPadProbeType mask,
849 GstPadProbeCallback callback,
851 GDestroyNotify destroy_data);
852 void gst_pad_remove_probe (GstPad *pad, gulong id);
854 gboolean gst_pad_is_blocked (GstPad *pad);
855 gboolean gst_pad_is_blocking (GstPad *pad);
857 void gst_pad_mark_reconfigure (GstPad *pad);
858 gboolean gst_pad_check_reconfigure (GstPad *pad);
860 void gst_pad_set_element_private (GstPad *pad, gpointer priv);
861 gpointer gst_pad_get_element_private (GstPad *pad);
863 GstPadTemplate* gst_pad_get_pad_template (GstPad *pad);
865 GstEvent* gst_pad_get_sticky_event (GstPad *pad, GstEventType event_type);
866 GstFlowReturn gst_pad_sticky_events_foreach (GstPad *pad, GstPadStickyEventsForeachFunction foreach_func, gpointer user_data);
868 /* data passing setup functions */
869 void gst_pad_set_activate_function (GstPad *pad, GstPadActivateFunction activate);
870 void gst_pad_set_activatepull_function (GstPad *pad, GstPadActivateModeFunction activatepull);
871 void gst_pad_set_activatepush_function (GstPad *pad, GstPadActivateModeFunction activatepush);
872 void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
873 void gst_pad_set_chain_list_function (GstPad *pad, GstPadChainListFunction chainlist);
874 void gst_pad_set_getrange_function (GstPad *pad, GstPadGetRangeFunction get);
875 void gst_pad_set_event_function (GstPad *pad, GstPadEventFunction event);
878 void gst_pad_set_link_function (GstPad *pad, GstPadLinkFunction link);
879 void gst_pad_set_unlink_function (GstPad *pad, GstPadUnlinkFunction unlink);
881 gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad);
882 GstPadLinkReturn gst_pad_link (GstPad *srcpad, GstPad *sinkpad);
883 GstPadLinkReturn gst_pad_link_full (GstPad *srcpad, GstPad *sinkpad, GstPadLinkCheck flags);
884 gboolean gst_pad_unlink (GstPad *srcpad, GstPad *sinkpad);
885 gboolean gst_pad_is_linked (GstPad *pad);
887 GstPad* gst_pad_get_peer (GstPad *pad);
889 /* capsnego functions */
890 void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps);
891 void gst_pad_set_acceptcaps_function (GstPad *pad, GstPadAcceptCapsFunction acceptcaps);
892 void gst_pad_set_fixatecaps_function (GstPad *pad, GstPadFixateCapsFunction fixatecaps);
894 GstCaps* gst_pad_get_pad_template_caps (GstPad *pad);
896 /* capsnego function for linked/unlinked pads */
897 GstCaps * gst_pad_get_current_caps (GstPad * pad);
898 gboolean gst_pad_has_current_caps (GstPad * pad);
899 GstCaps * gst_pad_get_caps (GstPad * pad, GstCaps *filter);
900 void gst_pad_fixate_caps (GstPad * pad, GstCaps *caps);
901 gboolean gst_pad_accept_caps (GstPad * pad, GstCaps *caps);
902 gboolean gst_pad_set_caps (GstPad * pad, GstCaps *caps);
904 GstCaps * gst_pad_peer_get_caps (GstPad * pad, GstCaps *filter);
905 gboolean gst_pad_peer_accept_caps (GstPad * pad, GstCaps *caps);
907 /* capsnego for linked pads */
908 GstCaps * gst_pad_get_allowed_caps (GstPad * pad);
911 gint64 gst_pad_get_offset (GstPad *pad);
912 void gst_pad_set_offset (GstPad *pad, gint64 offset);
914 /* data passing functions to peer */
915 GstFlowReturn gst_pad_push (GstPad *pad, GstBuffer *buffer);
916 GstFlowReturn gst_pad_push_list (GstPad *pad, GstBufferList *list);
917 GstFlowReturn gst_pad_pull_range (GstPad *pad, guint64 offset, guint size,
919 gboolean gst_pad_push_event (GstPad *pad, GstEvent *event);
920 gboolean gst_pad_event_default (GstPad *pad, GstEvent *event);
922 /* data passing functions on pad */
923 GstFlowReturn gst_pad_chain (GstPad *pad, GstBuffer *buffer);
924 GstFlowReturn gst_pad_chain_list (GstPad *pad, GstBufferList *list);
925 GstFlowReturn gst_pad_get_range (GstPad *pad, guint64 offset, guint size,
927 gboolean gst_pad_send_event (GstPad *pad, GstEvent *event);
930 gboolean gst_pad_start_task (GstPad *pad, GstTaskFunction func,
932 gboolean gst_pad_pause_task (GstPad *pad);
933 gboolean gst_pad_stop_task (GstPad *pad);
936 void gst_pad_set_iterate_internal_links_function (GstPad * pad,
937 GstPadIterIntLinkFunction iterintlink);
938 GstIterator * gst_pad_iterate_internal_links (GstPad * pad);
939 GstIterator * gst_pad_iterate_internal_links_default (GstPad * pad);
942 /* generic query function */
943 void gst_pad_set_query_type_function (GstPad *pad, GstPadQueryTypeFunction type_func);
944 const GstQueryType* gst_pad_get_query_types (GstPad *pad);
945 const GstQueryType* gst_pad_get_query_types_default (GstPad *pad);
947 gboolean gst_pad_query (GstPad *pad, GstQuery *query);
948 gboolean gst_pad_peer_query (GstPad *pad, GstQuery *query);
949 void gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query);
950 gboolean gst_pad_query_default (GstPad *pad, GstQuery *query);
952 /* misc helper functions */
953 gboolean gst_pad_forward (GstPad *pad, GstPadForwardFunction forward,
958 #endif /* __GST_PAD_H__ */