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 #include <gst/gstobject.h>
30 #include <gst/gstbuffer.h>
31 #include <gst/gstcaps.h>
32 #include <gst/gstevent.h>
33 #include <gst/gstprobe.h>
34 #include <gst/gstquery.h>
35 #include <gst/gstqueryutils.h>
36 #include <gst/gsttask.h>
41 GST_EXPORT GType _gst_pad_type;
42 GST_EXPORT GType _gst_real_pad_type;
43 GST_EXPORT GType _gst_ghost_pad_type;
48 #define GST_TYPE_PAD (_gst_pad_type)
49 #define GST_IS_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD))
50 #define GST_IS_PAD_FAST(obj) (G_OBJECT_TYPE(obj) == GST_TYPE_REAL_PAD || \
51 G_OBJECT_TYPE(obj) == GST_TYPE_GHOST_PAD)
52 #define GST_IS_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD))
53 #define GST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad))
54 #define GST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass))
55 #define GST_PAD_CAST(obj) ((GstPad*)(obj))
60 #define GST_TYPE_REAL_PAD (_gst_real_pad_type)
61 #define GST_IS_REAL_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_REAL_PAD))
62 #define GST_IS_REAL_PAD_FAST(obj) (G_OBJECT_TYPE(obj) == GST_TYPE_REAL_PAD)
63 #define GST_IS_REAL_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_REAL_PAD))
64 #define GST_REAL_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_REAL_PAD, GstRealPad))
65 #define GST_REAL_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_REAL_PAD, GstRealPadClass))
66 #define GST_REAL_PAD_CAST(obj) ((GstRealPad*)(obj))
71 #define GST_TYPE_GHOST_PAD (_gst_ghost_pad_type)
72 #define GST_IS_GHOST_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GHOST_PAD))
73 #define GST_IS_GHOST_PAD_FAST(obj) (G_OBJECT_TYPE(obj) == GST_TYPE_GHOST_PAD)
74 #define GST_IS_GHOST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GHOST_PAD))
75 #define GST_GHOST_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GHOST_PAD, GstGhostPad))
76 #define GST_GHOST_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GHOST_PAD, GstGhostPadClass))
77 #define GST_GHOST_PAD_CAST(obj) ((GstGhostPad*)(obj))
80 /*typedef struct _GstPad GstPad; */
81 /*typedef struct _GstPadClass GstPadClass;*/
82 typedef struct _GstRealPad GstRealPad;
83 typedef struct _GstRealPadClass GstRealPadClass;
84 typedef struct _GstGhostPad GstGhostPad;
85 typedef struct _GstGhostPadClass GstGhostPadClass;
86 /*typedef struct _GstPadTemplate GstPadTemplate;*/
87 /*typedef struct _GstPadTemplateClass GstPadTemplateClass;*/
88 typedef struct _GstStaticPadTemplate GstStaticPadTemplate;
89 typedef struct _GstPadLink GstPadLink;
92 GST_PAD_LINK_NOSCHED = -5, /* pads cannot cooperate in scheduling */
93 GST_PAD_LINK_NOFORMAT = -4, /* pads do not have common format */
94 GST_PAD_LINK_REFUSED = -3, /* refused for some reason */
95 GST_PAD_LINK_WRONG_DIRECTION = -2, /* pads have wrong direction */
96 GST_PAD_LINK_WAS_LINKED = -1, /* pad was already linked */
97 GST_PAD_LINK_OK = 0, /* link ok */
100 #define GST_PAD_LINK_FAILED(ret) ((ret) < GST_PAD_LINK_OK)
101 #define GST_PAD_LINK_SUCCESSFUL(ret) ((ret) >= GST_PAD_LINK_OK)
104 GST_FLOW_OK = 0, /* data passing was ok */
105 GST_FLOW_RESEND = 1, /* resend buffer, possibly with new caps */
106 GST_FLOW_ERROR = -1, /* some (fatal) error occured */
107 GST_FLOW_NOT_CONNECTED = -2, /* pad is not connected */
108 GST_FLOW_NOT_NEGOTIATED = -3, /* pad is not negotiated */
109 GST_FLOW_WRONG_STATE = -4, /* pad is in wrong state */
110 GST_FLOW_UNEXPECTED = -5, /* did not expect anything, this is not fatal */
111 GST_FLOW_NOT_SUPPORTED = -6 /* function not supported */
120 #define GST_PAD_MODE_ACTIVATE(mode) ((mode) != GST_ACTIVATE_NONE)
122 /* convenience functions */
123 #ifdef G_HAVE_ISO_VARARGS
124 #define GST_PAD_QUERY_TYPE_FUNCTION(functionname, ...) GST_QUERY_TYPE_FUNCTION (GstPad *, functionname, __VA_ARGS__);
125 #define GST_PAD_FORMATS_FUNCTION(functionname, ...) GST_FORMATS_FUNCTION (GstPad *, functionname, __VA_ARGS__);
126 #define GST_PAD_EVENT_MASK_FUNCTION(functionname, ...) GST_EVENT_MASK_FUNCTION (GstPad *, functionname, __VA_ARGS__);
127 #elif defined(G_HAVE_GNUC_VARARGS)
128 #define GST_PAD_QUERY_TYPE_FUNCTION(functionname, a...) GST_QUERY_TYPE_FUNCTION (GstPad *, functionname, a);
129 #define GST_PAD_FORMATS_FUNCTION(functionname, a...) GST_FORMATS_FUNCTION (GstPad *, functionname, a);
130 #define GST_PAD_EVENT_MASK_FUNCTION(functionname, a...) GST_EVENT_MASK_FUNCTION (GstPad *, functionname, a);
135 typedef gboolean (*GstPadActivateFunction) (GstPad *pad, GstActivateMode mode);
138 typedef void (*GstPadLoopFunction) (GstPad *pad);
139 typedef GstFlowReturn (*GstPadChainFunction) (GstPad *pad, GstBuffer *buffer);
140 typedef GstFlowReturn (*GstPadGetRangeFunction) (GstPad *pad, guint64 offset,
141 guint length, GstBuffer **buffer);
142 typedef gboolean (*GstPadCheckGetRangeFunction) (GstPad *pad);
143 typedef gboolean (*GstPadEventFunction) (GstPad *pad, GstEvent *event);
145 /* old, deprecated convert/query/format functions */
146 typedef gboolean (*GstPadConvertFunction) (GstPad *pad,
147 GstFormat src_format, gint64 src_value,
148 GstFormat *dest_format, gint64 *dest_value);
149 typedef gboolean (*GstPadQueryFunction) (GstPad *pad, GstQueryType type,
150 GstFormat *format, gint64 *value);
151 typedef GList* (*GstPadIntLinkFunction) (GstPad *pad);
152 typedef const GstFormat* (*GstPadFormatsFunction) (GstPad *pad);
153 typedef const GstEventMask* (*GstPadEventMaskFunction) (GstPad *pad);
154 typedef const GstQueryType* (*GstPadQueryTypeFunction) (GstPad *pad);
156 /* generic query function */
157 typedef gboolean (*GstPadQuery2Function) (GstPad *pad, GstQuery *query);
160 typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, GstPad *peer);
161 typedef void (*GstPadUnlinkFunction) (GstPad *pad);
164 typedef GstCaps* (*GstPadGetCapsFunction) (GstPad *pad);
165 typedef gboolean (*GstPadSetCapsFunction) (GstPad *pad, GstCaps *caps);
166 typedef gboolean (*GstPadAcceptCapsFunction) (GstPad *pad, GstCaps *caps);
167 typedef GstCaps* (*GstPadFixateCapsFunction) (GstPad *pad, GstCaps *caps);
168 typedef GstBuffer* (*GstPadBufferAllocFunction) (GstPad *pad, guint64 offset, guint size,
171 typedef gboolean (*GstPadDispatcherFunction) (GstPad *pad, gpointer data);
173 typedef void (*GstPadBlockCallback) (GstPad *pad, gboolean blocked, gpointer user_data);
182 GST_PAD_ACTIVE = GST_OBJECT_FLAG_LAST,
188 GST_PAD_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8
194 gpointer element_private;
196 GstPadTemplate *padtemplate; /* the template for this pad */
198 gpointer _gst_reserved[GST_PADDING];
201 struct _GstPadClass {
202 GstObjectClass parent_class;
204 gpointer _gst_reserved[GST_PADDING];
210 /* direction cannot change after creating the pad */
211 GstPadDirection direction;
213 /*< public >*/ /* with STREAM_LOCK */
214 /* streaming rec_lock */
215 GStaticRecMutex *stream_rec_lock;
217 /*< public >*/ /* with PREROLL_LOCK */
218 GMutex *preroll_lock;
221 /*< public >*/ /* with LOCK */
222 /* block cond, mutex is from the object */
224 GstPadBlockCallback block_callback;
227 /* the pad capabilities */
229 GstPadGetCapsFunction getcapsfunc;
230 GstPadSetCapsFunction setcapsfunc;
231 GstPadAcceptCapsFunction acceptcapsfunc;
232 GstPadFixateCapsFunction fixatecapsfunc;
234 GstPadActivateFunction activatefunc;
237 GstPadLinkFunction linkfunc;
238 GstPadUnlinkFunction unlinkfunc;
241 gpointer sched_private;
243 /* data transport functions */
244 GstPadLoopFunction loopfunc;
245 GstPadChainFunction chainfunc;
246 GstPadCheckGetRangeFunction checkgetrangefunc;
247 GstPadGetRangeFunction getrangefunc;
248 GstPadEventFunction eventfunc;
250 GstPadEventMaskFunction eventmaskfunc;
254 guint32 ghostpads_cookie;
256 /* old, deprecated query/convert/formats functions */
257 GstPadConvertFunction convertfunc;
258 GstPadQueryFunction queryfunc;
259 GstPadFormatsFunction formatsfunc;
260 GstPadQueryTypeFunction querytypefunc;
261 GstPadIntLinkFunction intlinkfunc;
263 GstPadBufferAllocFunction bufferallocfunc;
265 GstProbeDispatcher probedisp;
267 /* generic query method */
268 GstPadQuery2Function query2func;
271 /* fixme: bring back to gst_padding when old query functions go away */
272 gpointer _gst_reserved[GST_PADDING - 1];
275 struct _GstRealPadClass {
276 GstPadClass parent_class;
278 /* signal callbacks */
279 void (*linked) (GstPad *pad, GstPad *peer);
280 void (*unlinked) (GstPad *pad, GstPad *peer);
281 void (*request_link) (GstPad *pad);
284 gpointer _gst_reserved[GST_PADDING];
287 struct _GstGhostPad {
292 gpointer _gst_reserved[GST_PADDING];
295 struct _GstGhostPadClass {
296 GstPadClass parent_class;
298 gpointer _gst_reserved[GST_PADDING];
302 /***** helper macros *****/
304 #define GST_PAD_NAME(pad) (GST_OBJECT_NAME(pad))
305 #define GST_PAD_PARENT(pad) (GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad)))
306 #define GST_PAD_ELEMENT_PRIVATE(pad) (GST_PAD_CAST(pad)->element_private)
307 #define GST_PAD_PAD_TEMPLATE(pad) (GST_PAD_CAST(pad)->padtemplate)
310 #define GST_RPAD_DIRECTION(pad) (GST_REAL_PAD_CAST(pad)->direction)
311 #define GST_RPAD_TASK(pad) (GST_REAL_PAD_CAST(pad)->task)
312 #define GST_RPAD_ACTIVATEFUNC(pad) (GST_REAL_PAD_CAST(pad)->activatefunc)
313 #define GST_RPAD_LOOPFUNC(pad) (GST_REAL_PAD_CAST(pad)->loopfunc)
314 #define GST_RPAD_CHAINFUNC(pad) (GST_REAL_PAD_CAST(pad)->chainfunc)
315 #define GST_RPAD_CHECKGETRANGEFUNC(pad) (GST_REAL_PAD_CAST(pad)->checkgetrangefunc)
316 #define GST_RPAD_GETRANGEFUNC(pad) (GST_REAL_PAD_CAST(pad)->getrangefunc)
317 #define GST_RPAD_EVENTFUNC(pad) (GST_REAL_PAD_CAST(pad)->eventfunc)
318 #define GST_RPAD_CONVERTFUNC(pad) (GST_REAL_PAD_CAST(pad)->convertfunc)
319 #define GST_RPAD_QUERYFUNC(pad) (GST_REAL_PAD_CAST(pad)->queryfunc)
320 #define GST_RPAD_INTLINKFUNC(pad) (GST_REAL_PAD_CAST(pad)->intlinkfunc)
321 #define GST_RPAD_FORMATSFUNC(pad) (GST_REAL_PAD_CAST(pad)->formatsfunc)
322 #define GST_RPAD_QUERYTYPEFUNC(pad) (GST_REAL_PAD_CAST(pad)->querytypefunc)
323 #define GST_RPAD_EVENTMASKFUNC(pad) (GST_REAL_PAD_CAST(pad)->eventmaskfunc)
324 #define GST_RPAD_QUERY2FUNC(pad) (GST_REAL_PAD_CAST(pad)->query2func)
326 #define GST_RPAD_PEER(pad) (GST_REAL_PAD_CAST(pad)->peer)
327 #define GST_RPAD_LINKFUNC(pad) (GST_REAL_PAD_CAST(pad)->linkfunc)
328 #define GST_RPAD_UNLINKFUNC(pad) (GST_REAL_PAD_CAST(pad)->unlinkfunc)
330 #define GST_RPAD_CAPS(pad) (GST_REAL_PAD_CAST(pad)->caps)
331 #define GST_RPAD_GETCAPSFUNC(pad) (GST_REAL_PAD_CAST(pad)->getcapsfunc)
332 #define GST_RPAD_SETCAPSFUNC(pad) (GST_REAL_PAD_CAST(pad)->setcapsfunc)
333 #define GST_RPAD_ACCEPTCAPSFUNC(pad) (GST_REAL_PAD_CAST(pad)->acceptcapsfunc)
334 #define GST_RPAD_FIXATECAPSFUNC(pad) (GST_REAL_PAD_CAST(pad)->fixatecapsfunc)
336 #define GST_RPAD_BUFFERALLOCFUNC(pad) (GST_REAL_PAD_CAST(pad)->bufferallocfunc)
338 #define GST_RPAD_IS_LINKED(pad) (GST_RPAD_PEER(pad) != NULL)
339 #define GST_RPAD_IS_ACTIVE(pad) (GST_FLAG_IS_SET (pad, GST_PAD_ACTIVE))
340 #define GST_RPAD_IS_BLOCKED(pad) (GST_FLAG_IS_SET (pad, GST_PAD_BLOCKED))
341 #define GST_RPAD_IS_FLUSHING(pad) (GST_FLAG_IS_SET (pad, GST_PAD_FLUSHING))
342 #define GST_RPAD_IS_IN_GETCAPS(pad) (GST_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS))
343 #define GST_RPAD_IS_IN_SETCAPS(pad) (GST_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS))
344 #define GST_RPAD_IS_USABLE(pad) (GST_RPAD_IS_LINKED (pad) && \
345 GST_RPAD_IS_ACTIVE(pad) && GST_RPAD_IS_ACTIVE(GST_RPAD_PEER (pad)))
346 #define GST_RPAD_IS_SRC(pad) (GST_RPAD_DIRECTION(pad) == GST_PAD_SRC)
347 #define GST_RPAD_IS_SINK(pad) (GST_RPAD_DIRECTION(pad) == GST_PAD_SINK)
349 #define GST_STREAM_GET_LOCK(pad) (GST_PAD_REALIZE(pad)->stream_rec_lock)
350 #define GST_STREAM_LOCK(pad) (g_static_rec_mutex_lock(GST_STREAM_GET_LOCK(pad)))
351 #define GST_STREAM_TRYLOCK(pad) (g_static_rec_mutex_trylock(GST_STREAM_GET_LOCK(pad)))
352 #define GST_STREAM_UNLOCK(pad) (g_static_rec_mutex_unlock(GST_STREAM_GET_LOCK(pad)))
354 #define GST_PREROLL_GET_LOCK(pad) (GST_PAD_REALIZE(pad)->preroll_lock)
355 #define GST_PREROLL_LOCK(pad) (g_mutex_lock(GST_PREROLL_GET_LOCK(pad)))
356 #define GST_PREROLL_TRYLOCK(pad) (g_mutex_trylock(GST_PREROLL_GET_LOCK(pad)))
357 #define GST_PREROLL_UNLOCK(pad) (g_mutex_unlock(GST_PREROLL_GET_LOCK(pad)))
358 #define GST_PREROLL_GET_COND(pad) (GST_PAD_REALIZE(pad)->preroll_cond)
359 #define GST_PREROLL_WAIT(pad) g_cond_wait (GST_PREROLL_GET_COND (pad), GST_PREROLL_GET_LOCK (pad))
360 #define GST_PREROLL_TIMED_WAIT(pad, timeval) g_cond_timed_wait (GST_PREROLL_GET_COND (pad), GST_PREROLL_GET_LOCK (pad),\
362 #define GST_PREROLL_SIGNAL(pad) g_cond_signal (GST_PREROLL_GET_COND (pad));
363 #define GST_PREROLL_BROADCAST(pad) g_cond_broadcast (GST_PREROLL_GET_COND (pad));
365 #define GST_PAD_BLOCK_GET_COND(pad) (GST_PAD_REALIZE(pad)->block_cond)
366 #define GST_PAD_BLOCK_WAIT(pad) (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_GET_LOCK (pad)))
367 #define GST_PAD_BLOCK_SIGNAL(pad) (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad)))
370 #define GST_GPAD_REALPAD(pad) (((GstGhostPad *)(pad))->realpad)
372 /* Generic, be VERY carefull with these macros as the ghostpad could be lost */
373 #define GST_PAD_REALIZE(pad) (GST_IS_REAL_PAD(pad) ? ((GstRealPad *)(pad)) : GST_GPAD_REALPAD(pad))
374 #define GST_PAD_DIRECTION(pad) GST_RPAD_DIRECTION(GST_PAD_REALIZE(pad))
375 #define GST_PAD_CAPS(pad) GST_RPAD_CAPS(GST_PAD_REALIZE (pad))
376 #define GST_PAD_PEER(pad) GST_PAD_CAST(GST_RPAD_PEER(GST_PAD_REALIZE(pad)))
378 /* Some check functions (unused?) */
379 #define GST_PAD_IS_LINKED(pad) (GST_RPAD_IS_LINKED(GST_PAD_REALIZE(pad)))
380 #define GST_PAD_IS_ACTIVE(pad) (GST_RPAD_IS_ACTIVE(GST_PAD_REALIZE(pad)))
381 #define GST_PAD_IS_BLOCKED(pad) (GST_RPAD_IS_BLOCKED(GST_PAD_REALIZE(pad)))
382 #define GST_PAD_IS_NEGOTIATING(pad) (GST_RPAD_IS_NEGOTIATING(GST_PAD_REALIZE(pad)))
383 #define GST_PAD_IS_IN_GETCAPS(pad) (GST_RPAD_IS_IN_GETCAPS(GST_PAD_REALIZE(pad)))
384 #define GST_PAD_IS_IN_SETCAPS(pad) (GST_RPAD_IS_IN_SETCAPS(GST_PAD_REALIZE(pad)))
385 #define GST_PAD_IS_USABLE(pad) (GST_RPAD_IS_USABLE(GST_PAD_REALIZE(pad)))
386 #define GST_PAD_CAN_PULL(pad) (GST_RPAD_CAN_PULL(GST_PAD_REALIZE(pad)))
387 #define GST_PAD_IS_SRC(pad) (GST_RPAD_IS_SRC(GST_PAD_REALIZE(pad)))
388 #define GST_PAD_IS_SINK(pad) (GST_RPAD_IS_SINK(GST_PAD_REALIZE(pad)))
390 /***** PadTemplate *****/
391 #define GST_TYPE_PAD_TEMPLATE (gst_pad_template_get_type ())
392 #define GST_PAD_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD_TEMPLATE,GstPadTemplate))
393 #define GST_PAD_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD_TEMPLATE,GstPadTemplateClass))
394 #define GST_IS_PAD_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD_TEMPLATE))
395 #define GST_IS_PAD_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD_TEMPLATE))
403 #define GST_PAD_TEMPLATE_NAME_TEMPLATE(templ) (((GstPadTemplate *)(templ))->name_template)
404 #define GST_PAD_TEMPLATE_DIRECTION(templ) (((GstPadTemplate *)(templ))->direction)
405 #define GST_PAD_TEMPLATE_PRESENCE(templ) (((GstPadTemplate *)(templ))->presence)
406 #define GST_PAD_TEMPLATE_CAPS(templ) (((GstPadTemplate *)(templ))->caps)
409 GST_PAD_TEMPLATE_FIXED = GST_OBJECT_FLAG_LAST,
411 GST_PAD_TEMPLATE_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4
412 } GstPadTemplateFlags;
414 #define GST_PAD_TEMPLATE_IS_FIXED(templ) (GST_FLAG_IS_SET(templ, GST_PAD_TEMPLATE_FIXED))
416 struct _GstPadTemplate {
419 gchar *name_template;
420 GstPadDirection direction;
421 GstPadPresence presence;
424 gpointer _gst_reserved[GST_PADDING];
427 struct _GstPadTemplateClass {
428 GstObjectClass parent_class;
430 /* signal callbacks */
431 void (*pad_created) (GstPadTemplate *templ, GstPad *pad);
433 gpointer _gst_reserved[GST_PADDING];
436 struct _GstStaticPadTemplate {
437 gchar *name_template;
438 GstPadDirection direction;
439 GstPadPresence presence;
440 GstStaticCaps static_caps;
443 #define GST_STATIC_PAD_TEMPLATE(padname, dir, pres, caps) \
445 /* name_template */ padname, \
446 /* direction */ dir, \
447 /* presence */ pres, \
452 GType gst_pad_get_type (void);
453 GType gst_real_pad_get_type (void);
454 GType gst_ghost_pad_get_type (void);
457 GstPad* gst_pad_new (const gchar *name, GstPadDirection direction);
458 GstPad* gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name);
459 GstPad* gst_pad_custom_new (GType type, const gchar *name, GstPadDirection direction);
460 GstPad* gst_pad_custom_new_from_template (GType type, GstPadTemplate *templ, const gchar *name);
462 #define gst_pad_get_name(pad) gst_object_get_name(GST_OBJECT(pad))
463 #define gst_pad_set_name(pad,name) gst_object_set_name(GST_OBJECT(pad),name)
464 #define gst_pad_get_parent(pad) GST_ELEMENT(gst_object_get_parent(GST_OBJECT(pad)))
465 #define gst_pad_set_parent(pad,parent) gst_object_set_parent(GST_OBJECT(pad),parent)
466 GstElement* gst_pad_get_real_parent (GstPad *pad);
469 GstPadDirection gst_pad_get_direction (GstPad *pad);
471 gboolean gst_pad_set_active (GstPad *pad, GstActivateMode mode);
472 gboolean gst_pad_peer_set_active (GstPad *pad, GstActivateMode mode);
473 gboolean gst_pad_is_active (GstPad *pad);
474 gboolean gst_pad_set_blocked (GstPad *pad, gboolean blocked);
475 gboolean gst_pad_set_blocked_async (GstPad *pad, gboolean blocked,
476 GstPadBlockCallback callback, gpointer user_data);
477 gboolean gst_pad_is_blocked (GstPad *pad);
479 void gst_pad_set_element_private (GstPad *pad, gpointer priv);
480 gpointer gst_pad_get_element_private (GstPad *pad);
482 GstPadTemplate* gst_pad_get_pad_template (GstPad *pad);
484 void gst_pad_set_bufferalloc_function (GstPad *pad, GstPadBufferAllocFunction bufalloc);
485 GstBuffer* gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size,
488 /* data passing setup functions */
489 void gst_pad_set_activate_function (GstPad *pad, GstPadActivateFunction activate);
490 void gst_pad_set_loop_function (GstPad *pad, GstPadLoopFunction loop);
491 void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
492 void gst_pad_set_getrange_function (GstPad *pad, GstPadGetRangeFunction get);
493 void gst_pad_set_checkgetrange_function (GstPad *pad, GstPadCheckGetRangeFunction check);
494 void gst_pad_set_event_function (GstPad *pad, GstPadEventFunction event);
495 void gst_pad_set_event_mask_function (GstPad *pad, GstPadEventMaskFunction mask_func);
496 G_CONST_RETURN GstEventMask*
497 gst_pad_get_event_masks (GstPad *pad);
498 G_CONST_RETURN GstEventMask*
499 gst_pad_get_event_masks_default (GstPad *pad);
502 void gst_pad_set_link_function (GstPad *pad, GstPadLinkFunction link);
503 void gst_pad_set_unlink_function (GstPad *pad, GstPadUnlinkFunction unlink);
505 GstPadLinkReturn gst_pad_link (GstPad *srcpad, GstPad *sinkpad);
506 gboolean gst_pad_unlink (GstPad *srcpad, GstPad *sinkpad);
507 gboolean gst_pad_is_linked (GstPad *pad);
509 GstPad* gst_pad_get_peer (GstPad *pad);
510 GstPad* gst_pad_realize (GstPad *pad);
512 /* capsnego functions */
513 void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps);
514 void gst_pad_set_acceptcaps_function (GstPad *pad, GstPadAcceptCapsFunction acceptcaps);
515 void gst_pad_set_fixatecaps_function (GstPad *pad, GstPadFixateCapsFunction fixatecaps);
516 void gst_pad_set_setcaps_function (GstPad *pad, GstPadSetCapsFunction setcaps);
518 G_CONST_RETURN GstCaps* gst_pad_get_pad_template_caps (GstPad *pad);
520 /* capsnego function for connected/unconnected pads */
521 GstCaps * gst_pad_get_caps (GstPad * pad);
522 GstCaps* gst_pad_fixate_caps (GstPad * pad, GstCaps *caps);
523 gboolean gst_pad_accept_caps (GstPad * pad, GstCaps *caps);
524 gboolean gst_pad_set_caps (GstPad * pad, GstCaps *caps);
526 GstCaps * gst_pad_peer_get_caps (GstPad * pad);
527 gboolean gst_pad_peer_accept_caps (GstPad * pad, GstCaps *caps);
529 /* capsnego for connected pads */
530 GstCaps * gst_pad_get_allowed_caps (GstPad * srcpad);
531 GstCaps * gst_pad_get_negotiated_caps (GstPad * pad);
533 /* data passing functions */
534 GstFlowReturn gst_pad_push (GstPad *pad, GstBuffer *buffer);
535 gboolean gst_pad_check_pull_range (GstPad *pad);
536 GstFlowReturn gst_pad_pull_range (GstPad *pad, guint64 offset, guint size,
538 gboolean gst_pad_push_event (GstPad *pad, GstEvent *event);
539 gboolean gst_pad_send_event (GstPad *pad, GstEvent *event);
540 gboolean gst_pad_event_default (GstPad *pad, GstEvent *event);
543 gboolean gst_pad_start_task (GstPad *pad);
544 gboolean gst_pad_pause_task (GstPad *pad);
545 gboolean gst_pad_stop_task (GstPad *pad);
547 /* convert/query/format functions */
548 void gst_pad_set_formats_function (GstPad *pad,
549 GstPadFormatsFunction formats);
550 G_CONST_RETURN GstFormat*
551 gst_pad_get_formats (GstPad *pad);
552 G_CONST_RETURN GstFormat*
553 gst_pad_get_formats_default (GstPad *pad);
555 void gst_pad_set_convert_function (GstPad *pad, GstPadConvertFunction convert);
556 gboolean gst_pad_convert (GstPad *pad,
557 GstFormat src_format, gint64 src_value,
558 GstFormat *dest_format, gint64 *dest_value);
559 gboolean gst_pad_convert_default (GstPad *pad,
560 GstFormat src_format, gint64 src_value,
561 GstFormat *dest_format, gint64 *dest_value);
563 void gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query);
564 void gst_pad_set_query_type_function (GstPad *pad, GstPadQueryTypeFunction type_func);
565 G_CONST_RETURN GstQueryType*
566 gst_pad_get_query_types (GstPad *pad);
567 G_CONST_RETURN GstQueryType*
568 gst_pad_get_query_types_default (GstPad *pad);
569 gboolean gst_pad_query (GstPad *pad, GstQueryType type,
570 GstFormat *format, gint64 *value);
571 gboolean gst_pad_query_default (GstPad *pad, GstQueryType type,
572 GstFormat *format, gint64 *value);
574 void gst_pad_set_internal_link_function (GstPad *pad, GstPadIntLinkFunction intlink);
575 GList* gst_pad_get_internal_links (GstPad *pad);
576 GList* gst_pad_get_internal_links_default (GstPad *pad);
578 gboolean gst_pad_query2 (GstPad *pad, GstQuery *query);
579 void gst_pad_set_query2_function (GstPad *pad, GstPadQuery2Function query);
580 gboolean gst_pad_query2_default (GstPad *pad, GstQuery *query);
582 /* util query functions */
583 gboolean gst_pad_query_position (GstPad *pad, GstFormat *format,
584 gint64 *cur, gint64 *end);
586 /* misc helper functions */
587 gboolean gst_pad_dispatcher (GstPad *pad, GstPadDispatcherFunction dispatch,
591 #define gst_pad_add_probe(pad, probe) \
592 (gst_probe_dispatcher_add_probe (&(GST_PAD_REALIZE (pad)->probedisp), probe))
593 #define gst_pad_remove_probe(pad, probe) \
594 (gst_probe_dispatcher_remove_probe (&(GST_PAD_REALIZE (pad)->probedisp), probe))
596 #ifndef GST_DISABLE_LOADSAVE
597 void gst_pad_load_and_link (xmlNodePtr self, GstObject *parent);
602 GstPad* gst_ghost_pad_new (const gchar *name, GstPad *pad);
605 /* templates and factories */
606 GType gst_pad_template_get_type (void);
608 GstPadTemplate* gst_pad_template_new (const gchar *name_template,
609 GstPadDirection direction, GstPadPresence presence,
612 GstPadTemplate * gst_static_pad_template_get (GstStaticPadTemplate *pad_template);
613 GstCaps* gst_static_pad_template_get_caps (GstStaticPadTemplate *templ);
614 GstCaps* gst_pad_template_get_caps (GstPadTemplate *templ);
616 #ifndef GST_DISABLE_LOADSAVE
617 xmlNodePtr gst_ghost_pad_save_thyself (GstPad *pad,
624 #endif /* __GST_PAD_H__ */