Remove old query functions. Ported old code.
[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 #include <gst/gstqueryutils.h>
36 #include <gst/gsttask.h>
37
38
39 G_BEGIN_DECLS
40
41 GST_EXPORT GType _gst_pad_type;
42 GST_EXPORT GType _gst_real_pad_type;
43 GST_EXPORT GType _gst_ghost_pad_type;
44
45 /*
46  * Pad base class
47  */
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))
56
57 /* 
58  * Real Pads
59  */
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))
67
68 /*
69  * Ghost Pads
70  */
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))
78
79
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;
90
91 typedef enum {
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 */
98 } GstPadLinkReturn;
99
100 #define GST_PAD_LINK_FAILED(ret) ((ret) < GST_PAD_LINK_OK)
101 #define GST_PAD_LINK_SUCCESSFUL(ret) ((ret) >= GST_PAD_LINK_OK)
102
103 typedef enum {
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 */
112 } GstFlowReturn;
113
114 typedef enum {
115   GST_ACTIVATE_NONE,
116   GST_ACTIVATE_PUSH,
117   GST_ACTIVATE_PULL,
118 } GstActivateMode;
119
120 #define GST_PAD_MODE_ACTIVATE(mode) ((mode) != GST_ACTIVATE_NONE)
121
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);
131 #endif
132
133  
134 /* pad states */
135 typedef gboolean                (*GstPadActivateFunction)       (GstPad *pad, GstActivateMode mode);
136
137 /* data passing */
138 typedef GstFlowReturn           (*GstPadChainFunction)          (GstPad *pad, GstBuffer *buffer);
139 typedef GstFlowReturn           (*GstPadGetRangeFunction)       (GstPad *pad, guint64 offset, 
140                                                                  guint length, GstBuffer **buffer);
141 typedef gboolean                (*GstPadEventFunction)          (GstPad *pad, GstEvent *event);
142
143 /* deprecate me, check range should use seeking query, loop function is internal */
144 typedef gboolean                (*GstPadCheckGetRangeFunction)  (GstPad *pad); 
145 typedef void                    (*GstPadLoopFunction)           (GstPad *pad);
146
147 /* internal links */
148 typedef GList*                  (*GstPadIntLinkFunction)        (GstPad *pad);
149
150 /* generic query function */
151 typedef const GstQueryType*     (*GstPadQueryTypeFunction)      (GstPad *pad);
152 typedef gboolean                (*GstPadQueryFunction)          (GstPad *pad, GstQuery *query);
153
154 /* linking */
155 typedef GstPadLinkReturn        (*GstPadLinkFunction)           (GstPad *pad, GstPad *peer);
156 typedef void                    (*GstPadUnlinkFunction)         (GstPad *pad);
157
158 /* caps nego */
159 typedef GstCaps*                (*GstPadGetCapsFunction)        (GstPad *pad);
160 typedef gboolean                (*GstPadSetCapsFunction)        (GstPad *pad, GstCaps *caps);
161 typedef gboolean                (*GstPadAcceptCapsFunction)     (GstPad *pad, GstCaps *caps);
162 typedef GstCaps*                (*GstPadFixateCapsFunction)     (GstPad *pad, GstCaps *caps);
163 typedef GstBuffer*              (*GstPadBufferAllocFunction)    (GstPad *pad, guint64 offset, guint size,
164                                                                  GstCaps *caps);
165 /* misc */
166 typedef gboolean                (*GstPadDispatcherFunction)     (GstPad *pad, gpointer data);
167
168 typedef void                    (*GstPadBlockCallback)          (GstPad *pad, gboolean blocked, gpointer user_data);
169
170 typedef enum {
171   GST_PAD_UNKNOWN,
172   GST_PAD_SRC,
173   GST_PAD_SINK
174 } GstPadDirection;
175
176 typedef enum {
177   GST_PAD_ACTIVE                = GST_OBJECT_FLAG_LAST,
178   GST_PAD_BLOCKED,
179   GST_PAD_FLUSHING,
180   GST_PAD_IN_GETCAPS,
181   GST_PAD_IN_SETCAPS,
182
183   GST_PAD_FLAG_LAST             = GST_OBJECT_FLAG_LAST + 8
184 } GstPadFlags;
185
186 struct _GstPad {
187   GstObject             object;
188
189   gpointer              element_private;
190
191   GstPadTemplate        *padtemplate;   /* the template for this pad */
192
193   gpointer _gst_reserved[GST_PADDING];
194 };
195
196 struct _GstPadClass {
197   GstObjectClass parent_class;
198
199   gpointer _gst_reserved[GST_PADDING];
200 };
201
202 struct _GstRealPad {
203   GstPad                         pad;
204
205   /* direction cannot change after creating the pad */
206   GstPadDirection                direction;
207
208   /*< public >*/ /* with STREAM_LOCK */
209   /* streaming rec_lock */
210   GStaticRecMutex               *stream_rec_lock;
211   GstTask                       *task;
212   /*< public >*/ /* with PREROLL_LOCK */
213   GMutex                        *preroll_lock;
214   GCond                         *preroll_cond;
215
216   /*< public >*/ /* with LOCK */
217   /* block cond, mutex is from the object */
218   GCond                         *block_cond;
219   GstPadBlockCallback            block_callback;
220   gpointer                       block_data;
221
222   /* the pad capabilities */
223   GstCaps                       *caps;
224   GstPadGetCapsFunction          getcapsfunc;
225   GstPadSetCapsFunction          setcapsfunc;
226   GstPadAcceptCapsFunction       acceptcapsfunc;
227   GstPadFixateCapsFunction       fixatecapsfunc;
228
229   GstPadActivateFunction         activatefunc;
230
231   /* pad link */
232   GstPadLinkFunction             linkfunc;
233   GstPadUnlinkFunction           unlinkfunc;
234   GstRealPad                    *peer;
235
236   gpointer                       sched_private;
237
238   /* data transport functions */
239   GstPadLoopFunction             loopfunc;
240   GstPadChainFunction            chainfunc;
241   GstPadCheckGetRangeFunction    checkgetrangefunc;
242   GstPadGetRangeFunction         getrangefunc;
243   GstPadEventFunction            eventfunc;
244
245   /* ghostpads */
246   GList                         *ghostpads;
247   guint32                        ghostpads_cookie;
248
249   /* generic query method */
250   GstPadQueryTypeFunction        querytypefunc;
251   GstPadQueryFunction            queryfunc;
252
253   /* internal links */
254   GstPadIntLinkFunction          intlinkfunc;
255
256   GstPadBufferAllocFunction      bufferallocfunc;
257
258   GstProbeDispatcher             probedisp;
259
260   /*< private >*/
261   gpointer _gst_reserved[GST_PADDING];
262 };
263
264 struct _GstRealPadClass {
265   GstPadClass   parent_class;
266
267   /* signal callbacks */
268   void          (*linked)               (GstPad *pad, GstPad *peer);
269   void          (*unlinked)             (GstPad *pad, GstPad *peer);
270   void          (*request_link)         (GstPad *pad);
271
272   /*< private >*/
273   gpointer _gst_reserved[GST_PADDING];
274 };
275
276 struct _GstGhostPad {
277   GstPad pad;
278
279   GstRealPad *realpad;
280
281   gpointer _gst_reserved[GST_PADDING];
282 };
283
284 struct _GstGhostPadClass {
285   GstPadClass parent_class;
286
287   gpointer _gst_reserved[GST_PADDING];
288 };
289
290
291 /***** helper macros *****/
292 /* GstPad */
293 #define GST_PAD_NAME(pad)               (GST_OBJECT_NAME(pad))
294 #define GST_PAD_PARENT(pad)             (GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad)))
295 #define GST_PAD_ELEMENT_PRIVATE(pad)    (GST_PAD_CAST(pad)->element_private)
296 #define GST_PAD_PAD_TEMPLATE(pad)       (GST_PAD_CAST(pad)->padtemplate)
297
298 /* GstRealPad */
299 #define GST_RPAD_DIRECTION(pad)         (GST_REAL_PAD_CAST(pad)->direction)
300 #define GST_RPAD_TASK(pad)              (GST_REAL_PAD_CAST(pad)->task)
301 #define GST_RPAD_ACTIVATEFUNC(pad)      (GST_REAL_PAD_CAST(pad)->activatefunc)
302 #define GST_RPAD_LOOPFUNC(pad)          (GST_REAL_PAD_CAST(pad)->loopfunc)
303 #define GST_RPAD_CHAINFUNC(pad)         (GST_REAL_PAD_CAST(pad)->chainfunc)
304 #define GST_RPAD_CHECKGETRANGEFUNC(pad) (GST_REAL_PAD_CAST(pad)->checkgetrangefunc)
305 #define GST_RPAD_GETRANGEFUNC(pad)      (GST_REAL_PAD_CAST(pad)->getrangefunc)
306 #define GST_RPAD_EVENTFUNC(pad)         (GST_REAL_PAD_CAST(pad)->eventfunc)
307 #define GST_RPAD_QUERYTYPEFUNC(pad)     (GST_REAL_PAD_CAST(pad)->querytypefunc)
308 #define GST_RPAD_QUERYFUNC(pad)         (GST_REAL_PAD_CAST(pad)->queryfunc)
309 #define GST_RPAD_INTLINKFUNC(pad)       (GST_REAL_PAD_CAST(pad)->intlinkfunc)
310
311 #define GST_RPAD_PEER(pad)              (GST_REAL_PAD_CAST(pad)->peer)
312 #define GST_RPAD_LINKFUNC(pad)          (GST_REAL_PAD_CAST(pad)->linkfunc)
313 #define GST_RPAD_UNLINKFUNC(pad)        (GST_REAL_PAD_CAST(pad)->unlinkfunc)
314
315 #define GST_RPAD_CAPS(pad)              (GST_REAL_PAD_CAST(pad)->caps)
316 #define GST_RPAD_GETCAPSFUNC(pad)       (GST_REAL_PAD_CAST(pad)->getcapsfunc)
317 #define GST_RPAD_SETCAPSFUNC(pad)       (GST_REAL_PAD_CAST(pad)->setcapsfunc)
318 #define GST_RPAD_ACCEPTCAPSFUNC(pad)    (GST_REAL_PAD_CAST(pad)->acceptcapsfunc)
319 #define GST_RPAD_FIXATECAPSFUNC(pad)    (GST_REAL_PAD_CAST(pad)->fixatecapsfunc)
320
321 #define GST_RPAD_BUFFERALLOCFUNC(pad)   (GST_REAL_PAD_CAST(pad)->bufferallocfunc)
322
323 #define GST_RPAD_IS_LINKED(pad)         (GST_RPAD_PEER(pad) != NULL)
324 #define GST_RPAD_IS_ACTIVE(pad)         (GST_FLAG_IS_SET (pad, GST_PAD_ACTIVE))
325 #define GST_RPAD_IS_BLOCKED(pad)        (GST_FLAG_IS_SET (pad, GST_PAD_BLOCKED))
326 #define GST_RPAD_IS_FLUSHING(pad)       (GST_FLAG_IS_SET (pad, GST_PAD_FLUSHING))
327 #define GST_RPAD_IS_IN_GETCAPS(pad)     (GST_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS))
328 #define GST_RPAD_IS_IN_SETCAPS(pad)     (GST_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS))
329 #define GST_RPAD_IS_USABLE(pad)         (GST_RPAD_IS_LINKED (pad) && \
330                                          GST_RPAD_IS_ACTIVE(pad) && GST_RPAD_IS_ACTIVE(GST_RPAD_PEER (pad)))
331 #define GST_RPAD_IS_SRC(pad)            (GST_RPAD_DIRECTION(pad) == GST_PAD_SRC)
332 #define GST_RPAD_IS_SINK(pad)           (GST_RPAD_DIRECTION(pad) == GST_PAD_SINK)
333
334 #define GST_STREAM_GET_LOCK(pad)        (GST_PAD_REALIZE(pad)->stream_rec_lock)
335 #define GST_STREAM_LOCK(pad)            (g_static_rec_mutex_lock(GST_STREAM_GET_LOCK(pad)))
336 #define GST_STREAM_TRYLOCK(pad)         (g_static_rec_mutex_trylock(GST_STREAM_GET_LOCK(pad)))
337 #define GST_STREAM_UNLOCK(pad)          (g_static_rec_mutex_unlock(GST_STREAM_GET_LOCK(pad)))
338
339 #define GST_PREROLL_GET_LOCK(pad)       (GST_PAD_REALIZE(pad)->preroll_lock)
340 #define GST_PREROLL_LOCK(pad)           (g_mutex_lock(GST_PREROLL_GET_LOCK(pad)))
341 #define GST_PREROLL_TRYLOCK(pad)        (g_mutex_trylock(GST_PREROLL_GET_LOCK(pad)))
342 #define GST_PREROLL_UNLOCK(pad)         (g_mutex_unlock(GST_PREROLL_GET_LOCK(pad)))
343 #define GST_PREROLL_GET_COND(pad)       (GST_PAD_REALIZE(pad)->preroll_cond)
344 #define GST_PREROLL_WAIT(pad)           g_cond_wait (GST_PREROLL_GET_COND (pad), GST_PREROLL_GET_LOCK (pad))
345 #define GST_PREROLL_TIMED_WAIT(pad, timeval) g_cond_timed_wait (GST_PREROLL_GET_COND (pad), GST_PREROLL_GET_LOCK (pad),\
346                                              timeval)
347 #define GST_PREROLL_SIGNAL(pad)         g_cond_signal (GST_PREROLL_GET_COND (pad));
348 #define GST_PREROLL_BROADCAST(pad)      g_cond_broadcast (GST_PREROLL_GET_COND (pad));
349
350 #define GST_PAD_BLOCK_GET_COND(pad)     (GST_PAD_REALIZE(pad)->block_cond)
351 #define GST_PAD_BLOCK_WAIT(pad)         (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_GET_LOCK (pad)))
352 #define GST_PAD_BLOCK_SIGNAL(pad)       (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad)))
353
354 /* GstGhostPad */
355 #define GST_GPAD_REALPAD(pad)           (((GstGhostPad *)(pad))->realpad)
356
357 /* Generic, be VERY carefull with these macros as the ghostpad could be lost */
358 #define GST_PAD_REALIZE(pad)            (GST_IS_REAL_PAD(pad) ? ((GstRealPad *)(pad)) : GST_GPAD_REALPAD(pad))
359 #define GST_PAD_DIRECTION(pad)          GST_RPAD_DIRECTION(GST_PAD_REALIZE(pad))
360 #define GST_PAD_CAPS(pad)               GST_RPAD_CAPS(GST_PAD_REALIZE (pad))
361 #define GST_PAD_PEER(pad)               GST_PAD_CAST(GST_RPAD_PEER(GST_PAD_REALIZE(pad)))
362
363 /* Some check functions (unused?) */
364 #define GST_PAD_IS_LINKED(pad)          (GST_RPAD_IS_LINKED(GST_PAD_REALIZE(pad)))
365 #define GST_PAD_IS_ACTIVE(pad)          (GST_RPAD_IS_ACTIVE(GST_PAD_REALIZE(pad)))
366 #define GST_PAD_IS_BLOCKED(pad)         (GST_RPAD_IS_BLOCKED(GST_PAD_REALIZE(pad)))
367 #define GST_PAD_IS_FLUSHING(pad)        (GST_RPAD_IS_FLUSHING(GST_PAD_REALIZE(pad)))
368 #define GST_PAD_IS_IN_GETCAPS(pad)      (GST_RPAD_IS_IN_GETCAPS(GST_PAD_REALIZE(pad)))
369 #define GST_PAD_IS_IN_SETCAPS(pad)      (GST_RPAD_IS_IN_SETCAPS(GST_PAD_REALIZE(pad)))
370 #define GST_PAD_IS_USABLE(pad)          (GST_RPAD_IS_USABLE(GST_PAD_REALIZE(pad)))
371 #define GST_PAD_IS_SRC(pad)             (GST_RPAD_IS_SRC(GST_PAD_REALIZE(pad)))
372 #define GST_PAD_IS_SINK(pad)            (GST_RPAD_IS_SINK(GST_PAD_REALIZE(pad)))
373
374 /***** PadTemplate *****/
375 #define GST_TYPE_PAD_TEMPLATE           (gst_pad_template_get_type ())
376 #define GST_PAD_TEMPLATE(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD_TEMPLATE,GstPadTemplate))
377 #define GST_PAD_TEMPLATE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD_TEMPLATE,GstPadTemplateClass))
378 #define GST_IS_PAD_TEMPLATE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD_TEMPLATE))
379 #define GST_IS_PAD_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD_TEMPLATE))
380
381 typedef enum {
382   GST_PAD_ALWAYS,
383   GST_PAD_SOMETIMES,
384   GST_PAD_REQUEST
385 } GstPadPresence;
386
387 #define GST_PAD_TEMPLATE_NAME_TEMPLATE(templ)   (((GstPadTemplate *)(templ))->name_template)
388 #define GST_PAD_TEMPLATE_DIRECTION(templ)       (((GstPadTemplate *)(templ))->direction)
389 #define GST_PAD_TEMPLATE_PRESENCE(templ)        (((GstPadTemplate *)(templ))->presence)
390 #define GST_PAD_TEMPLATE_CAPS(templ)            (((GstPadTemplate *)(templ))->caps)
391
392 typedef enum {
393   GST_PAD_TEMPLATE_FIXED        = GST_OBJECT_FLAG_LAST,
394
395   GST_PAD_TEMPLATE_FLAG_LAST    = GST_OBJECT_FLAG_LAST + 4
396 } GstPadTemplateFlags;
397
398 #define GST_PAD_TEMPLATE_IS_FIXED(templ)        (GST_FLAG_IS_SET(templ, GST_PAD_TEMPLATE_FIXED))
399
400 struct _GstPadTemplate {
401   GstObject        object;
402
403   gchar           *name_template;
404   GstPadDirection  direction;
405   GstPadPresence   presence;
406   GstCaps         *caps;
407
408   gpointer _gst_reserved[GST_PADDING];
409 };
410
411 struct _GstPadTemplateClass {
412   GstObjectClass   parent_class;
413
414   /* signal callbacks */
415   void (*pad_created)   (GstPadTemplate *templ, GstPad *pad);
416
417   gpointer _gst_reserved[GST_PADDING];
418 };
419
420 struct _GstStaticPadTemplate {
421   gchar           *name_template;
422   GstPadDirection  direction;
423   GstPadPresence   presence;
424   GstStaticCaps   static_caps;
425 };
426
427 #define GST_STATIC_PAD_TEMPLATE(padname, dir, pres, caps) \
428   { \
429   /* name_template */    padname, \
430   /* direction */        dir, \
431   /* presence */         pres, \
432   /* caps */             caps \
433   }
434
435
436 GType                   gst_pad_get_type                        (void);
437 GType                   gst_real_pad_get_type                   (void);
438 GType                   gst_ghost_pad_get_type                  (void);
439
440 /* creating pads */
441 GstPad*                 gst_pad_new                             (const gchar *name, GstPadDirection direction);
442 GstPad*                 gst_pad_new_from_template               (GstPadTemplate *templ, const gchar *name);
443 GstPad*                 gst_pad_custom_new                      (GType type, const gchar *name, GstPadDirection direction);
444 GstPad*                 gst_pad_custom_new_from_template        (GType type, GstPadTemplate *templ, const gchar *name);
445
446 #define                 gst_pad_get_name(pad)                   gst_object_get_name(GST_OBJECT(pad))
447 #define                 gst_pad_set_name(pad,name)              gst_object_set_name(GST_OBJECT(pad),name)
448 #define                 gst_pad_get_parent(pad)                 GST_ELEMENT(gst_object_get_parent(GST_OBJECT(pad)))
449 #define                 gst_pad_set_parent(pad,parent)          gst_object_set_parent(GST_OBJECT(pad),parent)
450 GstElement*             gst_pad_get_real_parent                 (GstPad *pad);
451
452
453 GstPadDirection         gst_pad_get_direction                   (GstPad *pad);
454
455 gboolean                gst_pad_set_active                      (GstPad *pad, GstActivateMode mode);
456 gboolean                gst_pad_peer_set_active                 (GstPad *pad, GstActivateMode mode);
457 gboolean                gst_pad_is_active                       (GstPad *pad);
458 gboolean                gst_pad_set_blocked                     (GstPad *pad, gboolean blocked);
459 gboolean                gst_pad_set_blocked_async               (GstPad *pad, gboolean blocked,
460                                                                  GstPadBlockCallback callback, gpointer user_data);
461 gboolean                gst_pad_is_blocked                      (GstPad *pad);
462
463 void                    gst_pad_set_element_private             (GstPad *pad, gpointer priv);
464 gpointer                gst_pad_get_element_private             (GstPad *pad);
465
466 GstPadTemplate*         gst_pad_get_pad_template                (GstPad *pad);
467
468 void                    gst_pad_set_bufferalloc_function        (GstPad *pad, GstPadBufferAllocFunction bufalloc);
469 GstBuffer*              gst_pad_alloc_buffer                    (GstPad *pad, guint64 offset, gint size, 
470                                                                  GstCaps *caps);
471
472 /* data passing setup functions */
473 void                    gst_pad_set_activate_function           (GstPad *pad, GstPadActivateFunction activate);
474 void                    gst_pad_set_loop_function               (GstPad *pad, GstPadLoopFunction loop);
475 void                    gst_pad_set_chain_function              (GstPad *pad, GstPadChainFunction chain);
476 void                    gst_pad_set_getrange_function           (GstPad *pad, GstPadGetRangeFunction get);
477 void                    gst_pad_set_checkgetrange_function      (GstPad *pad, GstPadCheckGetRangeFunction check);
478 void                    gst_pad_set_event_function              (GstPad *pad, GstPadEventFunction event);
479
480 /* pad links */
481 void                    gst_pad_set_link_function               (GstPad *pad, GstPadLinkFunction link);
482 void                    gst_pad_set_unlink_function             (GstPad *pad, GstPadUnlinkFunction unlink);
483
484 GstPadLinkReturn        gst_pad_link                            (GstPad *srcpad, GstPad *sinkpad);
485 gboolean                gst_pad_unlink                          (GstPad *srcpad, GstPad *sinkpad);
486 gboolean                gst_pad_is_linked                       (GstPad *pad);
487
488 GstPad*                 gst_pad_get_peer                        (GstPad *pad);
489 GstPad*                 gst_pad_realize                         (GstPad *pad);
490
491 /* capsnego functions */
492 void                    gst_pad_set_getcaps_function            (GstPad *pad, GstPadGetCapsFunction getcaps);
493 void                    gst_pad_set_acceptcaps_function         (GstPad *pad, GstPadAcceptCapsFunction acceptcaps);
494 void                    gst_pad_set_fixatecaps_function         (GstPad *pad, GstPadFixateCapsFunction fixatecaps);
495 void                    gst_pad_set_setcaps_function            (GstPad *pad, GstPadSetCapsFunction setcaps);
496
497 G_CONST_RETURN GstCaps* gst_pad_get_pad_template_caps           (GstPad *pad);
498
499 /* capsnego function for connected/unconnected pads */
500 GstCaps *               gst_pad_get_caps                        (GstPad * pad);
501 GstCaps*                gst_pad_fixate_caps                     (GstPad * pad, GstCaps *caps);
502 gboolean                gst_pad_accept_caps                     (GstPad * pad, GstCaps *caps);
503 gboolean                gst_pad_set_caps                        (GstPad * pad, GstCaps *caps);
504
505 GstCaps *               gst_pad_peer_get_caps                   (GstPad * pad);
506 gboolean                gst_pad_peer_accept_caps                (GstPad * pad, GstCaps *caps);
507
508 /* capsnego for connected pads */
509 GstCaps *               gst_pad_get_allowed_caps                (GstPad * srcpad);
510 GstCaps *               gst_pad_get_negotiated_caps             (GstPad * pad);
511
512 /* data passing functions */
513 GstFlowReturn           gst_pad_push                            (GstPad *pad, GstBuffer *buffer);
514 gboolean                gst_pad_check_pull_range                (GstPad *pad);
515 GstFlowReturn           gst_pad_pull_range                      (GstPad *pad, guint64 offset, guint size,
516                                                                  GstBuffer **buffer);
517 gboolean                gst_pad_push_event                      (GstPad *pad, GstEvent *event);
518 gboolean                gst_pad_send_event                      (GstPad *pad, GstEvent *event);
519 gboolean                gst_pad_event_default                   (GstPad *pad, GstEvent *event);
520
521 /* pad tasks */
522 gboolean                gst_pad_start_task                      (GstPad *pad);
523 gboolean                gst_pad_pause_task                      (GstPad *pad);
524 gboolean                gst_pad_stop_task                       (GstPad *pad);
525
526 /* internal links */
527 void                    gst_pad_set_internal_link_function      (GstPad *pad, GstPadIntLinkFunction intlink);
528 GList*                  gst_pad_get_internal_links              (GstPad *pad);
529 GList*                  gst_pad_get_internal_links_default      (GstPad *pad);
530
531 /* generic query function */
532 void                    gst_pad_set_query_type_function         (GstPad *pad, GstPadQueryTypeFunction type_func);
533 G_CONST_RETURN GstQueryType*
534                         gst_pad_get_query_types                 (GstPad *pad);
535 G_CONST_RETURN GstQueryType*
536                         gst_pad_get_query_types_default         (GstPad *pad);
537
538 gboolean                gst_pad_query                           (GstPad *pad, GstQuery *query);
539 void                    gst_pad_set_query_function              (GstPad *pad, GstPadQueryFunction query);
540 gboolean                gst_pad_query_default                   (GstPad *pad, GstQuery *query);
541
542 /* misc helper functions */
543 gboolean                gst_pad_dispatcher                      (GstPad *pad, GstPadDispatcherFunction dispatch,
544                                                                  gpointer data);
545
546 /* probes */
547 #define                 gst_pad_add_probe(pad, probe) \
548                         (gst_probe_dispatcher_add_probe (&(GST_PAD_REALIZE (pad)->probedisp), probe))
549 #define                 gst_pad_remove_probe(pad, probe) \
550                         (gst_probe_dispatcher_remove_probe (&(GST_PAD_REALIZE (pad)->probedisp), probe))
551
552 #ifndef GST_DISABLE_LOADSAVE
553 void                    gst_pad_load_and_link                   (xmlNodePtr self, GstObject *parent);
554 #endif
555
556
557 /* ghostpads */
558 GstPad*                 gst_ghost_pad_new                       (const gchar *name, GstPad *pad);
559
560
561 /* templates and factories */
562 GType                   gst_pad_template_get_type               (void);
563
564 GstPadTemplate*         gst_pad_template_new                    (const gchar *name_template,
565                                                                  GstPadDirection direction, GstPadPresence presence,
566                                                                  GstCaps *caps);
567
568 GstPadTemplate *        gst_static_pad_template_get             (GstStaticPadTemplate *pad_template);
569 GstCaps*                gst_static_pad_template_get_caps        (GstStaticPadTemplate *templ);
570 GstCaps*                gst_pad_template_get_caps               (GstPadTemplate *templ);
571
572 #ifndef GST_DISABLE_LOADSAVE
573 xmlNodePtr              gst_ghost_pad_save_thyself              (GstPad *pad,
574                                                                  xmlNodePtr parent);
575 #endif
576
577
578 G_END_DECLS
579
580 #endif /* __GST_PAD_H__ */