Bump version number, we're now 0.9.0
[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., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23
24 #ifndef __GST_PAD_H__
25 #define __GST_PAD_H__
26
27 #include <gst/gstconfig.h>
28
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
36
37 G_BEGIN_DECLS
38
39 GST_EXPORT GType _gst_pad_type;
40 GST_EXPORT GType _gst_real_pad_type;
41 GST_EXPORT GType _gst_ghost_pad_type;
42
43 /*
44  * Pad base class
45  */
46 #define GST_TYPE_PAD                    (_gst_pad_type)
47 #define GST_IS_PAD(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD))
48 #define GST_IS_PAD_FAST(obj)            (G_OBJECT_TYPE(obj) == GST_TYPE_REAL_PAD || \
49                                          G_OBJECT_TYPE(obj) == GST_TYPE_GHOST_PAD)
50 #define GST_IS_PAD_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD))
51 #define GST_PAD(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad))
52 #define GST_PAD_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass))
53 #define GST_PAD_CAST(obj)               ((GstPad*)(obj))
54
55 /* 
56  * Real Pads
57  */
58 #define GST_TYPE_REAL_PAD               (_gst_real_pad_type)
59 #define GST_IS_REAL_PAD(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_REAL_PAD))
60 #define GST_IS_REAL_PAD_FAST(obj)       (G_OBJECT_TYPE(obj) == GST_TYPE_REAL_PAD)
61 #define GST_IS_REAL_PAD_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_REAL_PAD))
62 #define GST_REAL_PAD(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_REAL_PAD, GstRealPad))
63 #define GST_REAL_PAD_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_REAL_PAD, GstRealPadClass))
64 #define GST_REAL_PAD_CAST(obj)          ((GstRealPad*)(obj))
65
66 /*
67  * Ghost Pads
68  */
69 #define GST_TYPE_GHOST_PAD              (_gst_ghost_pad_type)
70 #define GST_IS_GHOST_PAD(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GHOST_PAD))
71 #define GST_IS_GHOST_PAD_FAST(obj)      (G_OBJECT_TYPE(obj) == GST_TYPE_GHOST_PAD)
72 #define GST_IS_GHOST_PAD_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_GHOST_PAD))
73 #define GST_GHOST_PAD(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GHOST_PAD, GstGhostPad))
74 #define GST_GHOST_PAD_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GHOST_PAD, GstGhostPadClass))
75 #define GST_GHOST_PAD_CAST(obj)         ((GstGhostPad*)(obj))
76
77
78 /*typedef struct _GstPad GstPad; */
79 /*typedef struct _GstPadClass GstPadClass;*/
80 typedef struct _GstRealPad GstRealPad;
81 typedef struct _GstRealPadClass GstRealPadClass;
82 typedef struct _GstGhostPad GstGhostPad;
83 typedef struct _GstGhostPadClass GstGhostPadClass;
84 /*typedef struct _GstPadTemplate GstPadTemplate;*/
85 /*typedef struct _GstPadTemplateClass GstPadTemplateClass;*/
86 typedef struct _GstStaticPadTemplate GstStaticPadTemplate;
87 typedef struct _GstPadLink GstPadLink;
88
89 typedef enum {
90   GST_PAD_LINK_REFUSED = -1,
91   GST_PAD_LINK_DELAYED =  0,
92   GST_PAD_LINK_OK      =  1,
93   GST_PAD_LINK_DONE    =  2
94 } GstPadLinkReturn;
95
96 #define GST_PAD_LINK_FAILED(ret) (ret < GST_PAD_LINK_OK)
97 #define GST_PAD_LINK_SUCCESSFUL(ret) (ret >= GST_PAD_LINK_OK)
98
99 typedef enum {
100   GST_FLOW_OK             =  0,         /* data passing was ok */
101   GST_FLOW_RESEND         =  1,         /* resend buffer, possibly with new caps */
102   GST_FLOW_ERROR          = -1,         /* some (fatal) error occured */
103   GST_FLOW_NOT_CONNECTED  = -2,         /* pad is not connected */
104   GST_FLOW_NOT_NEGOTIATED = -3,         /* pad is not negotiated */
105   GST_FLOW_WRONG_STATE    = -4,         /* pad is in wrong state */
106   GST_FLOW_UNEXPECTED     = -5,         /* did not expect anything, this is not fatal */
107   GST_FLOW_NOT_SUPPORTED  = -6          /* function not supported */
108 } GstFlowReturn;
109
110 typedef enum {
111   GST_ACTIVATE_NONE,
112   GST_ACTIVATE_PUSH,
113   GST_ACTIVATE_PULL,
114 } GstActivateMode;
115
116 /* convenience functions */
117 #ifdef G_HAVE_ISO_VARARGS
118 #define GST_PAD_QUERY_TYPE_FUNCTION(functionname, ...)  GST_QUERY_TYPE_FUNCTION (GstPad *, functionname, __VA_ARGS__);
119 #define GST_PAD_FORMATS_FUNCTION(functionname, ...)     GST_FORMATS_FUNCTION (GstPad *, functionname, __VA_ARGS__);
120 #define GST_PAD_EVENT_MASK_FUNCTION(functionname, ...)  GST_EVENT_MASK_FUNCTION (GstPad *, functionname, __VA_ARGS__);
121 #elif defined(G_HAVE_GNUC_VARARGS)
122 #define GST_PAD_QUERY_TYPE_FUNCTION(functionname, a...) GST_QUERY_TYPE_FUNCTION (GstPad *, functionname, a);
123 #define GST_PAD_FORMATS_FUNCTION(functionname, a...)    GST_FORMATS_FUNCTION (GstPad *, functionname, a);
124 #define GST_PAD_EVENT_MASK_FUNCTION(functionname, a...) GST_EVENT_MASK_FUNCTION (GstPad *, functionname, a);
125 #endif
126
127  
128 /* pad states */
129 typedef gboolean                (*GstPadActivateFunction)       (GstPad *pad, GstActivateMode mode);
130
131 /* this defines the functions used to chain buffers
132  * pad is the sink pad (so the same chain function can be used for N pads)
133  * buf is the buffer being passed */
134 typedef void                    (*GstPadChainFunction)          (GstPad *pad,GstData *data);
135 typedef GstData*                (*GstPadGetFunction)            (GstPad *pad);
136 typedef gboolean                (*GstPadEventFunction)          (GstPad *pad, GstEvent *event);
137
138 /* convert/query/format functions */
139 typedef gboolean                (*GstPadConvertFunction)        (GstPad *pad,
140                                                                  GstFormat src_format,  gint64  src_value,
141                                                                  GstFormat *dest_format, gint64 *dest_value);
142 typedef gboolean                (*GstPadQueryFunction)          (GstPad *pad, GstQueryType type,
143                                                                  GstFormat *format, gint64  *value);
144 typedef GList*                  (*GstPadIntLinkFunction)        (GstPad *pad);
145 typedef const GstFormat*        (*GstPadFormatsFunction)        (GstPad *pad);
146 typedef const GstEventMask*     (*GstPadEventMaskFunction)      (GstPad *pad);
147 typedef const GstQueryType*     (*GstPadQueryTypeFunction)      (GstPad *pad);
148
149 /* linking */
150 typedef GstPadLinkReturn        (*GstPadLinkFunction)           (GstPad *pad, const GstCaps *caps);
151 typedef void                    (*GstPadUnlinkFunction)         (GstPad *pad);
152
153 /* caps nego */
154 typedef GstCaps*                (*GstPadGetCapsFunction)        (GstPad *pad);
155 typedef GstCaps*                (*GstPadFixateFunction)         (GstPad *pad, const GstCaps *caps);
156 typedef GstBuffer*              (*GstPadBufferAllocFunction)    (GstPad *pad, guint64 offset, guint size);
157
158 /* misc */
159 typedef gboolean                (*GstPadDispatcherFunction)     (GstPad *pad, gpointer data);
160
161 typedef enum {
162   GST_PAD_UNKNOWN,
163   GST_PAD_SRC,
164   GST_PAD_SINK
165 } GstPadDirection;
166
167 typedef enum {
168   GST_PAD_ACTIVE                = GST_OBJECT_FLAG_LAST,
169   GST_PAD_NEGOTIATING,
170   GST_PAD_DISPATCHING,
171
172   GST_PAD_FLAG_LAST             = GST_OBJECT_FLAG_LAST + 8
173 } GstPadFlags;
174
175 struct _GstPad {
176   GstObject             object;
177
178   gpointer              element_private;
179
180   GstPadTemplate        *padtemplate;   /* the template for this pad */
181
182   gpointer _gst_reserved[GST_PADDING];
183 };
184
185 struct _GstPadClass {
186   GstObjectClass parent_class;
187
188   gpointer _gst_reserved[GST_PADDING];
189 };
190
191 typedef enum {
192   GST_RPAD_IN_GETFUNC = GST_PAD_FLAG_LAST,
193   GST_RPAD_IN_CHAINFUNC,
194   GST_RPAD_FLAG_LAST = GST_PAD_FLAG_LAST + 4
195 } GstRealPadFlags;
196
197 struct _GstRealPad {
198   GstPad                         pad;
199
200   /* direction cannot change after creating the pad */
201   GstPadDirection                direction;
202
203   /* the pad capabilities */
204   GstCaps                       *caps;
205   GstCaps                       *appfilter;
206   GstPadGetCapsFunction         getcapsfunc;
207   GstPadFixateFunction           appfixatefunc;
208   GstPadFixateFunction           fixatefunc;
209
210   /* pad link */
211   GstPadLinkFunction             linkfunc;
212   GstPadUnlinkFunction           unlinkfunc;
213   GstRealPad                    *peer;
214
215   gpointer                       sched_private;
216
217   /* data transport functions */
218   GstPadChainFunction            chainfunc;
219   GstPadChainFunction            chainhandler;
220   GstPadGetFunction              getfunc;
221   GstPadGetFunction              gethandler;
222   GstPadEventFunction            eventfunc;
223   GstPadEventFunction            eventhandler;
224
225   GstPadEventMaskFunction        eventmaskfunc;
226
227   /* ghostpads */
228   GList                         *ghostpads;
229   guint32                        ghostpads_cookie;
230
231   /* query/convert/formats functions */
232   GstPadConvertFunction          convertfunc;
233   GstPadQueryFunction            queryfunc;
234   GstPadFormatsFunction          formatsfunc;
235   GstPadQueryTypeFunction        querytypefunc;
236   GstPadIntLinkFunction          intlinkfunc;
237
238   GstPadBufferAllocFunction      bufferallocfunc;
239
240   GstProbeDispatcher             probedisp;
241
242   GstPadLink                    *link;
243   GstCaps                       *explicit_caps;
244
245   /*< private >*/
246   gpointer _gst_reserved[GST_PADDING];
247 };
248
249 struct _GstRealPadClass {
250   GstPadClass   parent_class;
251
252   /* signal callbacks */
253   void          (*linked)               (GstPad *pad, GstPad *peer);
254   void          (*unlinked)             (GstPad *pad, GstPad *peer);
255   GstPadFixateFunction           appfixatefunc;
256
257   void          (*caps_nego_failed)     (GstPad *pad, GstCaps *caps);
258
259   /*< private >*/
260   gpointer _gst_reserved[GST_PADDING];
261 };
262
263 struct _GstGhostPad {
264   GstPad pad;
265
266   GstRealPad *realpad;
267
268   gpointer _gst_reserved[GST_PADDING];
269 };
270
271 struct _GstGhostPadClass {
272   GstPadClass parent_class;
273
274   gpointer _gst_reserved[GST_PADDING];
275 };
276
277
278 /***** helper macros *****/
279 /* GstPad */
280 #define GST_PAD_NAME(pad)               (GST_OBJECT_NAME(pad))
281 #define GST_PAD_PARENT(pad)             (GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad)))
282 #define GST_PAD_ELEMENT_PRIVATE(pad)    (GST_PAD_CAST(pad)->element_private)
283 #define GST_PAD_PAD_TEMPLATE(pad)       (GST_PAD_CAST(pad)->padtemplate)
284
285 /* GstRealPad */
286 #define GST_RPAD_DIRECTION(pad)         (GST_REAL_PAD_CAST(pad)->direction)
287 #define GST_RPAD_CHAINFUNC(pad)         (GST_REAL_PAD_CAST(pad)->chainfunc)
288 #define GST_RPAD_CHAINHANDLER(pad)      (GST_REAL_PAD_CAST(pad)->chainhandler)
289 #define GST_RPAD_GETFUNC(pad)           (GST_REAL_PAD_CAST(pad)->getfunc)
290 #define GST_RPAD_GETHANDLER(pad)        (GST_REAL_PAD_CAST(pad)->gethandler)
291 #define GST_RPAD_EVENTFUNC(pad)         (GST_REAL_PAD_CAST(pad)->eventfunc)
292 #define GST_RPAD_EVENTHANDLER(pad)      (GST_REAL_PAD_CAST(pad)->eventhandler)
293 #define GST_RPAD_CONVERTFUNC(pad)       (GST_REAL_PAD_CAST(pad)->convertfunc)
294 #define GST_RPAD_QUERYFUNC(pad)         (GST_REAL_PAD_CAST(pad)->queryfunc)
295 #define GST_RPAD_INTLINKFUNC(pad)       (GST_REAL_PAD_CAST(pad)->intlinkfunc)
296 #define GST_RPAD_FORMATSFUNC(pad)       (GST_REAL_PAD_CAST(pad)->formatsfunc)
297 #define GST_RPAD_QUERYTYPEFUNC(pad)     (GST_REAL_PAD_CAST(pad)->querytypefunc)
298 #define GST_RPAD_EVENTMASKFUNC(pad)     (GST_REAL_PAD_CAST(pad)->eventmaskfunc)
299
300 #define GST_RPAD_PEER(pad)              (GST_REAL_PAD_CAST(pad)->peer)
301 #define GST_RPAD_LINKFUNC(pad)          (GST_REAL_PAD_CAST(pad)->linkfunc)
302 #define GST_RPAD_UNLINKFUNC(pad)        (GST_REAL_PAD_CAST(pad)->unlinkfunc)
303
304 #define GST_RPAD_CAPS(pad)              (GST_REAL_PAD_CAST(pad)->caps)
305 #define GST_RPAD_APPFILTER(pad)         (GST_REAL_PAD_CAST(pad)->appfilter)
306 #define GST_RPAD_GETCAPSFUNC(pad)       (GST_REAL_PAD_CAST(pad)->getcapsfunc)
307 #define GST_RPAD_FIXATEFUNC(pad)        (GST_REAL_PAD_CAST(pad)->fixatefunc)
308 #define GST_RPAD_LINK(pad)              (GST_REAL_PAD_CAST(pad)->link)
309 #define GST_RPAD_EXPLICIT_CAPS(pad)     (GST_REAL_PAD_CAST(pad)->explicit_caps)
310
311 #define GST_RPAD_BUFFERALLOCFUNC(pad)   (GST_REAL_PAD_CAST(pad)->bufferallocfunc)
312
313 #define GST_RPAD_IS_LINKED(pad)         (GST_RPAD_PEER(pad) != NULL)
314 #define GST_RPAD_IS_ACTIVE(pad)         (GST_FLAG_IS_SET (pad, GST_PAD_ACTIVE))
315 #define GST_RPAD_IS_USABLE(pad)         (GST_RPAD_IS_LINKED (pad) && \
316                                          GST_RPAD_IS_ACTIVE(pad) && GST_RPAD_IS_ACTIVE(GST_RPAD_PEER (pad)))
317 #define GST_RPAD_IS_SRC(pad)            (GST_RPAD_DIRECTION(pad) == GST_PAD_SRC)
318 #define GST_RPAD_IS_SINK(pad)           (GST_RPAD_DIRECTION(pad) == GST_PAD_SINK)
319
320 /* GstGhostPad */
321 #define GST_GPAD_REALPAD(pad)           (((GstGhostPad *)(pad))->realpad)
322
323 /* Generic */
324 #define GST_PAD_REALIZE(pad)            (GST_IS_REAL_PAD(pad) ? ((GstRealPad *)(pad)) : GST_GPAD_REALPAD(pad))
325 #define GST_PAD_DIRECTION(pad)          GST_RPAD_DIRECTION(GST_PAD_REALIZE(pad))
326 #define GST_PAD_CAPS(pad)               (gst_pad_get_negotiated_caps(GST_PAD (pad)))
327 #define GST_PAD_PEER(pad)               GST_PAD_CAST(GST_RPAD_PEER(GST_PAD_REALIZE(pad)))
328
329 /* Some check functions (unused?) */
330 #define GST_PAD_IS_LINKED(pad)          (GST_RPAD_IS_LINKED(GST_PAD_REALIZE(pad)))
331 #define GST_PAD_IS_ACTIVE(pad)          (GST_RPAD_IS_ACTIVE(GST_PAD_REALIZE(pad)))
332 #define GST_PAD_IS_NEGOTIATING(pad)     (GST_FLAG_IS_SET (pad, GST_PAD_NEGOTIATING))
333 #define GST_PAD_IS_DISPATCHING(pad)     (GST_FLAG_IS_SET (pad, GST_PAD_DISPATCHING))
334 #define GST_PAD_IS_USABLE(pad)          (GST_RPAD_IS_USABLE(GST_PAD_REALIZE(pad)))
335 #define GST_PAD_CAN_PULL(pad)           (GST_IS_REAL_PAD(pad) && GST_REAL_PAD(pad)->gethandler != NULL)
336 #define GST_PAD_IS_SRC(pad)             (GST_RPAD_IS_SRC(GST_PAD_REALIZE(pad)))
337 #define GST_PAD_IS_SINK(pad)            (GST_RPAD_IS_SINK(GST_PAD_REALIZE(pad)))
338
339 /***** PadTemplate *****/
340 #define GST_TYPE_PAD_TEMPLATE           (gst_pad_template_get_type ())
341 #define GST_PAD_TEMPLATE(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD_TEMPLATE,GstPadTemplate))
342 #define GST_PAD_TEMPLATE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD_TEMPLATE,GstPadTemplateClass))
343 #define GST_IS_PAD_TEMPLATE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD_TEMPLATE))
344 #define GST_IS_PAD_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD_TEMPLATE))
345
346 typedef enum {
347   GST_PAD_ALWAYS,
348   GST_PAD_SOMETIMES,
349   GST_PAD_REQUEST
350 } GstPadPresence;
351
352 #define GST_PAD_TEMPLATE_NAME_TEMPLATE(templ)   (((GstPadTemplate *)(templ))->name_template)
353 #define GST_PAD_TEMPLATE_DIRECTION(templ)       (((GstPadTemplate *)(templ))->direction)
354 #define GST_PAD_TEMPLATE_PRESENCE(templ)        (((GstPadTemplate *)(templ))->presence)
355 #define GST_PAD_TEMPLATE_CAPS(templ)            (((GstPadTemplate *)(templ))->caps)
356
357 typedef enum {
358   GST_PAD_TEMPLATE_FIXED        = GST_OBJECT_FLAG_LAST,
359
360   GST_PAD_TEMPLATE_FLAG_LAST    = GST_OBJECT_FLAG_LAST + 4
361 } GstPadTemplateFlags;
362
363 #define GST_PAD_TEMPLATE_IS_FIXED(templ)        (GST_FLAG_IS_SET(templ, GST_PAD_TEMPLATE_FIXED))
364
365 struct _GstPadTemplate {
366   GstObject        object;
367
368   gchar           *name_template;
369   GstPadDirection  direction;
370   GstPadPresence   presence;
371   GstCaps         *caps;
372
373   gpointer _gst_reserved[GST_PADDING];
374 };
375
376 struct _GstPadTemplateClass {
377   GstObjectClass   parent_class;
378
379   /* signal callbacks */
380   void (*pad_created)   (GstPadTemplate *templ, GstPad *pad);
381
382   gpointer _gst_reserved[GST_PADDING];
383 };
384
385 struct _GstStaticPadTemplate {
386   gchar           *name_template;
387   GstPadDirection  direction;
388   GstPadPresence   presence;
389   GstStaticCaps   static_caps;
390 };
391
392 #define GST_STATIC_PAD_TEMPLATE(padname, dir, pres, caps) \
393   { \
394   /* name_template */    padname, \
395   /* direction */        dir, \
396   /* presence */         pres, \
397   /* caps */             caps \
398   }
399
400
401 GType                   gst_pad_get_type                        (void);
402 GType                   gst_real_pad_get_type                   (void);
403 GType                   gst_ghost_pad_get_type                  (void);
404
405 /* creating pads */
406 GstPad*                 gst_pad_new                             (const gchar *name, GstPadDirection direction);
407 GstPad*                 gst_pad_new_from_template               (GstPadTemplate *templ, const gchar *name);
408 GstPad*                 gst_pad_custom_new                      (GType type, const gchar *name, GstPadDirection direction);
409 GstPad*                 gst_pad_custom_new_from_template        (GType type, GstPadTemplate *templ, const gchar *name);
410
411 #define                 gst_pad_get_name(pad)                   gst_object_get_name(GST_OBJECT(pad))
412 #define                 gst_pad_set_name(pad,name)              gst_object_set_name(GST_OBJECT(pad),name)
413 #define                 gst_pad_get_parent(pad)                 GST_ELEMENT(gst_object_get_parent(GST_OBJECT(pad)))
414 #define                 gst_pad_set_parent(pad,parent)          gst_object_set_parent(GST_OBJECT(pad),parent)
415 GstElement*             gst_pad_get_real_parent                 (GstPad *pad);
416
417
418 GstPadDirection         gst_pad_get_direction                   (GstPad *pad);
419
420 gboolean                gst_pad_set_active                      (GstPad *pad, gboolean active);
421 gboolean                gst_pad_is_active                       (GstPad *pad);
422
423 void                    gst_pad_set_element_private             (GstPad *pad, gpointer priv);
424 gpointer                gst_pad_get_element_private             (GstPad *pad);
425
426 GstScheduler*           gst_pad_get_scheduler                   (GstPad *pad);
427
428 GstPadTemplate*         gst_pad_get_pad_template                (GstPad *pad);
429
430 void                    gst_pad_set_bufferalloc_function                (GstPad *pad, GstPadBufferAllocFunction bufalloc);
431 GstBuffer*              gst_pad_alloc_buffer                    (GstPad *pad, guint64 offset, gint size);
432
433 /* data passing setup functions */
434 void                    gst_pad_set_chain_function              (GstPad *pad, GstPadChainFunction chain);
435 void                    gst_pad_set_get_function                (GstPad *pad, GstPadGetFunction get);
436 void                    gst_pad_set_event_function              (GstPad *pad, GstPadEventFunction event);
437 void                    gst_pad_set_event_mask_function         (GstPad *pad, GstPadEventMaskFunction mask_func);
438 G_CONST_RETURN GstEventMask*
439                         gst_pad_get_event_masks                 (GstPad *pad);
440 G_CONST_RETURN GstEventMask*
441                         gst_pad_get_event_masks_default         (GstPad *pad);
442
443 /* pad links */
444 void                    gst_pad_set_link_function               (GstPad *pad, GstPadLinkFunction link);
445 gboolean                gst_pad_can_link                        (GstPad *srcpad, GstPad *sinkpad);
446 gboolean                gst_pad_can_link_filtered               (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
447 void                    gst_pad_set_unlink_function             (GstPad *pad, GstPadUnlinkFunction unlink);
448
449 gboolean                gst_pad_link                            (GstPad *srcpad, GstPad *sinkpad);
450 gboolean                gst_pad_link_filtered                   (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
451 void                    gst_pad_unlink                          (GstPad *srcpad, GstPad *sinkpad);
452 gboolean                gst_pad_is_linked                       (GstPad *pad);
453
454 GstPad*                 gst_pad_get_peer                        (GstPad *pad);
455 GstPad*                 gst_pad_realize                         (GstPad *pad);
456
457 /* capsnego functions */
458 void                    gst_pad_set_getcaps_function            (GstPad *pad, GstPadGetCapsFunction getcaps);
459 void                    gst_pad_set_fixate_function             (GstPad *pad, GstPadFixateFunction fixate);
460 GstCaps *               gst_pad_proxy_getcaps                   (GstPad *pad);
461 GstCaps *               gst_pad_proxy_fixate                    (GstPad *pad, const GstCaps *caps);
462 gboolean                gst_pad_set_explicit_caps               (GstPad *pad, const GstCaps *caps);
463 void                    gst_pad_use_explicit_caps               (GstPad *pad);
464 gboolean                gst_pad_relink_filtered                 (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
465 GstPadLinkReturn        gst_pad_renegotiate                     (GstPad *pad);
466 void                    gst_pad_unnegotiate                     (GstPad *pad);
467 gboolean                gst_pad_try_relink_filtered             (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
468 void                    gst_pad_caps_change_notify              (GstPad *pad);
469
470 gboolean                gst_pad_recover_caps_error              (GstPad *pad, const GstCaps *allowed);
471
472 G_CONST_RETURN GstCaps* gst_pad_get_pad_template_caps           (GstPad *pad);
473
474 /* capsnego function for connected/unconnected pads */
475 GstCaps*                gst_pad_get_caps                        (GstPad *pad);
476 gboolean                gst_pad_set_caps                        (GstPad *pad, GstCaps *caps);
477 GstPadLinkReturn        gst_pad_try_set_caps                    (GstPad *pad, const GstCaps *caps);
478 GstPadLinkReturn        gst_pad_try_set_caps_nonfixed           (GstPad *pad, const GstCaps *caps);
479 gboolean                gst_pad_check_compatibility             (GstPad *srcpad, GstPad *sinkpad);
480
481 GstCaps *               gst_pad_peer_get_caps                   (GstPad * pad);
482
483 /* capsnego for connected pads */
484 GstCaps*                gst_pad_get_allowed_caps                (GstPad *pad);
485 G_CONST_RETURN GstCaps* gst_pad_get_negotiated_caps             (GstPad *pad);
486 gboolean                gst_pad_is_negotiated                   (GstPad *pad);
487
488
489 /* data passing functions */
490 void                    gst_pad_push                            (GstPad *pad, GstData *data);
491 GstData*                gst_pad_pull                            (GstPad *pad);
492 gboolean                gst_pad_send_event                      (GstPad *pad, GstEvent *event);
493 gboolean                gst_pad_event_default                   (GstPad *pad, GstEvent *event);
494 /* FIXME 0.9: rename to _select? Otherwise rename SchedulerClass pointer */
495 GstData *               gst_pad_collectv                        (GstPad **selected, const GList *padlist);
496 GstData *               gst_pad_collect                         (GstPad **selected, GstPad *pad, ...);
497 GstData *               gst_pad_collect_valist                  (GstPad **selected, GstPad *pad, va_list varargs);
498
499 /* convert/query/format functions */
500 void                    gst_pad_set_formats_function            (GstPad *pad,
501                                                                  GstPadFormatsFunction formats);
502 G_CONST_RETURN GstFormat*
503                         gst_pad_get_formats                     (GstPad *pad);
504 G_CONST_RETURN GstFormat*
505                         gst_pad_get_formats_default             (GstPad *pad);
506
507 void                    gst_pad_set_convert_function            (GstPad *pad, GstPadConvertFunction convert);
508 gboolean                gst_pad_convert                         (GstPad *pad,
509                                                                  GstFormat src_format,  gint64  src_value,
510                                                                  GstFormat *dest_format, gint64 *dest_value);
511 gboolean                gst_pad_convert_default                 (GstPad *pad,
512                                                                  GstFormat src_format,  gint64  src_value,
513                                                                  GstFormat *dest_format, gint64 *dest_value);
514
515 void                    gst_pad_set_query_function              (GstPad *pad, GstPadQueryFunction query);
516 void                    gst_pad_set_query_type_function         (GstPad *pad, GstPadQueryTypeFunction type_func);
517 G_CONST_RETURN GstQueryType*
518                         gst_pad_get_query_types                 (GstPad *pad);
519 G_CONST_RETURN GstQueryType*
520                         gst_pad_get_query_types_default         (GstPad *pad);
521 gboolean                gst_pad_query                           (GstPad *pad, GstQueryType type,
522                                                                  GstFormat *format, gint64 *value);
523 gboolean                gst_pad_query_default                   (GstPad *pad, GstQueryType type,
524                                                                  GstFormat *format, gint64 *value);
525
526 void                    gst_pad_set_internal_link_function      (GstPad *pad, GstPadIntLinkFunction intlink);
527 GList*                  gst_pad_get_internal_links              (GstPad *pad);
528 GList*                  gst_pad_get_internal_links_default      (GstPad *pad);
529
530 /* misc helper functions */
531 gboolean                gst_pad_dispatcher                      (GstPad *pad, GstPadDispatcherFunction dispatch,
532                                                                  gpointer data);
533
534 /* probes */
535 #define                 gst_pad_add_probe(pad, probe) \
536                         (gst_probe_dispatcher_add_probe (&(GST_PAD_REALIZE (pad)->probedisp), probe))
537 #define                 gst_pad_remove_probe(pad, probe) \
538                         (gst_probe_dispatcher_remove_probe (&(GST_PAD_REALIZE (pad)->probedisp), probe))
539
540 #ifndef GST_DISABLE_LOADSAVE
541 void                    gst_pad_load_and_link                   (xmlNodePtr self, GstObject *parent);
542 #endif
543
544
545 /* ghostpads */
546 GstPad*                 gst_ghost_pad_new                       (const gchar *name, GstPad *pad);
547
548
549 /* templates and factories */
550 GType                   gst_pad_template_get_type               (void);
551
552 GstPadTemplate*         gst_pad_template_new                    (const gchar *name_template,
553                                                                  GstPadDirection direction, GstPadPresence presence,
554                                                                  GstCaps *caps);
555
556 GstPadTemplate *        gst_static_pad_template_get             (GstStaticPadTemplate *pad_template);
557 const GstCaps*          gst_pad_template_get_caps               (GstPadTemplate *templ);
558
559 #ifndef GST_DISABLE_LOADSAVE
560 xmlNodePtr              gst_ghost_pad_save_thyself              (GstPad *pad,
561                                                                  xmlNodePtr parent);
562 #endif
563
564 /* for schedulers only */
565 void                    gst_pad_call_chain_function             (GstPad *pad, GstData *data);
566 GstData *               gst_pad_call_get_function               (GstPad *pad);
567
568 G_END_DECLS
569
570 #endif /* __GST_PAD_H__ */