*.*: Ran scripts/update-macros. Oh yes. gst/gstobject.h (GST_OBJECT_GET_LOCK, GST_OBJ...
[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/gstquery.h>
34 #include <gst/gsttask.h>
35
36 G_BEGIN_DECLS
37
38 /*
39  * Pad base class
40  */
41 #define GST_TYPE_PAD                    (gst_pad_get_type ())
42 #define GST_IS_PAD(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD))
43 #define GST_IS_PAD_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD))
44 #define GST_PAD(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PAD, GstPad))
45 #define GST_PAD_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD, GstPadClass))
46 #define GST_PAD_CAST(obj)               ((GstPad*)(obj))
47
48 /* FIXME: remove - its unused */
49 #define GST_IS_PAD_FAST(obj)            (G_OBJECT_TYPE(obj) == GST_TYPE_PAD)
50
51 typedef struct _GstPad GstPad;
52 typedef struct _GstPadClass GstPadClass;
53
54 /**
55  * GstPadLinkReturn:
56  * @GST_PAD_LINK_OK             : link succeeded
57  * @GST_PAD_LINK_WRONG_HIERARCHY: pads have no common grandparent
58  * @GST_PAD_LINK_WAS_LINKED     : pad was already linked
59  * @GST_PAD_LINK_WRONG_DIRECTION: pads have wrong direction
60  * @GST_PAD_LINK_NOFORMAT       : pads do not have common format
61  * @GST_PAD_LINK_NOSCHED        : pads cannot cooperate in scheduling
62  * @GST_PAD_LINK_REFUSED        : refused for some reason
63  */
64 typedef enum {
65   GST_PAD_LINK_OK               =  0,
66   GST_PAD_LINK_WRONG_HIERARCHY  = -1,
67   GST_PAD_LINK_WAS_LINKED       = -2,
68   GST_PAD_LINK_WRONG_DIRECTION  = -3,
69   GST_PAD_LINK_NOFORMAT         = -4,
70   GST_PAD_LINK_NOSCHED          = -5,
71   GST_PAD_LINK_REFUSED          = -6,
72 } GstPadLinkReturn;
73
74 /**
75  * GST_PAD_LINK_FAILED:
76  * @ret: the #GstPadLinkReturn value
77  *
78  * Macro to test if the given #GstPadLinkReturn value indicates a failed
79  * link step.
80  */
81 #define GST_PAD_LINK_FAILED(ret) ((ret) < GST_PAD_LINK_OK)
82
83 /**
84  * GST_PAD_LINK_SUCCESSFUL:
85  * @ret: the #GstPadLinkReturn value
86  *
87  * Macro to test if the given #GstPadLinkReturn value indicates a successful
88  * link step.
89  */
90 #define GST_PAD_LINK_SUCCESSFUL(ret) ((ret) >= GST_PAD_LINK_OK)
91
92 /**
93  * GstFlowReturn:
94  * @GST_FLOW_RESEND:             Resend buffer, possibly with new caps.
95  * @GST_FLOW_OK:                 Data passing was ok.
96  * @GST_FLOW_NOT_LINKED:         Pad is not linked.
97  * @GST_FLOW_WRONG_STATE:        Pad is in wrong state.
98  * @GST_FLOW_UNEXPECTED:         Did not expect anything, like after EOS.
99  * @GST_FLOW_NOT_NEGOTIATED:     Pad is not negotiated.
100  * @GST_FLOW_ERROR:              Some (fatal) error occured.
101  * @GST_FLOW_NOT_SUPPORTED:      This operation is not supported.
102  *
103  * The result of passing data to a linked pad.
104  */
105 typedef enum {
106   GST_FLOW_RESEND         =  1,
107   GST_FLOW_OK             =  0,
108   /* expected failures */
109   GST_FLOW_NOT_LINKED     = -1,
110   GST_FLOW_WRONG_STATE    = -2,
111   /* error cases */
112   GST_FLOW_UNEXPECTED     = -3,
113   GST_FLOW_NOT_NEGOTIATED = -4,
114   GST_FLOW_ERROR          = -5,
115   GST_FLOW_NOT_SUPPORTED  = -6
116 } GstFlowReturn;
117
118 /**
119  * GST_FLOW_IS_FATAL:
120  * @ret: a #GstFlowReturn value
121  *
122  * Macro to test if the given #GstFlowReturn value indicates a fatal
123  * error. This macro is mainly used in elements to decide when an error
124  * message should be posted on the bus.
125  */
126 #define GST_FLOW_IS_FATAL(ret) ((ret) <= GST_FLOW_UNEXPECTED)
127
128 G_CONST_RETURN gchar*   gst_flow_get_name       (GstFlowReturn ret);
129 GQuark                  gst_flow_to_quark       (GstFlowReturn ret);
130
131 /**
132  * GstActivateMode:
133  * @GST_ACTIVATE_NONE:           Pad will not handle dataflow
134  * @GST_ACTIVATE_PUSH:           Pad handles dataflow in downstream push mode
135  * @GST_ACTIVATE_PULL:           Pad handles dataflow in upstream pull mode
136  *
137  * The status of a GstPad. After activating a pad, which usually happens when the
138  * parent element goes from READY to PAUSED, the GstActivateMode defines if the
139  * pad operates in push or pull mode.
140  */
141 typedef enum {
142   GST_ACTIVATE_NONE,
143   GST_ACTIVATE_PUSH,
144   GST_ACTIVATE_PULL,
145 } GstActivateMode;
146
147 /**
148  * GST_PAD_MODE_ACTIVATE:
149  * @mode: a #GstActivateMode
150  *
151  * Macro to test if the given #GstActivateMode value indicates that datapassing
152  * is possible or not.
153  */
154 #define GST_PAD_MODE_ACTIVATE(mode) ((mode) != GST_ACTIVATE_NONE)
155
156 /* pad states */
157 typedef gboolean                (*GstPadActivateFunction)       (GstPad *pad);
158 typedef gboolean                (*GstPadActivateModeFunction)   (GstPad *pad, gboolean active);
159
160
161 /* data passing */
162 /**
163  * GstPadChainFunction:
164  * @pad: the #GstPad that performed the chain.
165  * @buffer: the #GstBuffer that is chained.
166  *
167  * A function that will be called on sinkpads when chaining buffers.
168  *
169  * Returns: GST_FLOW_OK for success
170  */
171 typedef GstFlowReturn           (*GstPadChainFunction)          (GstPad *pad, GstBuffer *buffer);
172 /**
173  * GstPadGetRangeFunction:
174  * @pad: the #GstPad to perform the getrange on.
175  * @offset: the offset of the range
176  * @length: the length of the range
177  * @buffer: a memory location to hold the result buffer
178  *
179  * This function will be called on sourcepads when a peer element
180  * request a buffer at the specified offset and length. If this function
181  * returns GST_FLOW_OK, the result buffer will be stored in @buffer. The 
182  * contents of @buffer is invalid for any other return value.
183  *
184  * Returns: GST_FLOW_OK for success
185  */
186 typedef GstFlowReturn           (*GstPadGetRangeFunction)       (GstPad *pad, guint64 offset,
187                                                                  guint length, GstBuffer **buffer);
188
189 /**
190  * GstPadEventFunction:
191  * @pad: the #GstPad to handle the event.
192  * @event: the #GstEvent to handle.
193  *
194  * Function signature to handle an event for the pad.
195  *
196  * Returns: TRUE if the pad could handle the event.
197  */
198 typedef gboolean                (*GstPadEventFunction)          (GstPad *pad, GstEvent *event);
199
200
201 /* deprecate me, check range should use seeking query */
202 typedef gboolean                (*GstPadCheckGetRangeFunction)  (GstPad *pad);
203
204
205 /* internal links */
206 /**
207  * GstPadIntLinkFunction:
208  * @pad: The #GstPad to query.
209  *
210  * The signature of the internal pad link function.
211  *
212  * Returns: a newly allocated #GList of pads that are linked to the given pad on
213  *  the inside of the parent element.
214  *  The caller must call g_list_free() on it after use.
215  */
216 typedef GList*                  (*GstPadIntLinkFunction)        (GstPad *pad);
217
218
219 /* generic query function */
220 /**
221  * GstPadQueryTypeFunction:
222  * @pad: a #GstPad to query
223  *
224  * The signature of the query types function.
225  *
226  * Returns: a constant array of query types
227  */
228 typedef const GstQueryType*     (*GstPadQueryTypeFunction)      (GstPad *pad);
229
230 /**
231  * GstPadQueryFunction:
232  * @pad: the #GstPad to query.
233  * @query: the #GstQuery object to execute
234  *
235  * The signature of the query function.
236  *
237  * Returns: TRUE if the query could be performed.
238  */
239 typedef gboolean                (*GstPadQueryFunction)          (GstPad *pad, GstQuery *query);
240
241
242 /* linking */
243 /**
244  * GstPadLinkFunction
245  * @pad: the #GstPad that is linked.
246  * @peer: the peer #GstPad of the link
247  *
248  * Function signature to handle a new link on the pad.
249  *
250  * Returns: the result of the link with the specified peer.
251  */
252 typedef GstPadLinkReturn        (*GstPadLinkFunction)           (GstPad *pad, GstPad *peer);
253 /**
254  * GstPadUnlinkFunction
255  * @pad: the #GstPad that is linked.
256  *
257  * Function signature to handle a unlinking the pad prom its peer.
258  */
259 typedef void                    (*GstPadUnlinkFunction)         (GstPad *pad);
260
261
262 /* caps nego */
263 /**
264  * GstPadGetCapsFunction:
265  * @pad: the #GstPad to get the capabilities of.
266  *
267  * Returns a copy of the capabilities of the specified pad. By default this
268  * function will return the pad template capabilities, but can optionally
269  * be overridden.
270  *
271  * Returns: a newly allocated copy #GstCaps of the pad.
272  */
273 typedef GstCaps*                (*GstPadGetCapsFunction)        (GstPad *pad);
274 typedef gboolean                (*GstPadSetCapsFunction)        (GstPad *pad, GstCaps *caps);
275 typedef gboolean                (*GstPadAcceptCapsFunction)     (GstPad *pad, GstCaps *caps);
276 typedef void                    (*GstPadFixateCapsFunction)     (GstPad *pad, GstCaps *caps);
277 typedef GstFlowReturn           (*GstPadBufferAllocFunction)    (GstPad *pad, guint64 offset, guint size,
278                                                                  GstCaps *caps, GstBuffer **buf);
279
280 /* misc */
281 /**
282  * GstPadDispatcherFunction:
283  * @pad: the #GstPad that is dispatched.
284  * @data: the gpointer to optional user data.
285  *
286  * A dispatcher function is called for all internally linked pads, see
287  * gst_pad_dispatcher().
288  *
289  * Returns: TRUE if the dispatching procedure has to be stopped.
290  */
291 typedef gboolean                (*GstPadDispatcherFunction)     (GstPad *pad, gpointer data);
292
293 /**
294  * GstPadBlockCallback:
295  * @pad: the #GstPad that is blockend or unblocked.
296  * @blocked: blocking state for the pad
297  * @user_data: the gpointer to optional user data.
298  *
299  * Callback used by gst_pad_set_blocked_async(). Gets called when the blocking
300  * operation succeeds.
301  */
302 typedef void                    (*GstPadBlockCallback)          (GstPad *pad, gboolean blocked, gpointer user_data);
303
304 /**
305  * GstPadDirection:
306  * @GST_PAD_UNKNOWN: direction is unknown.
307  * @GST_PAD_SRC: the pad is a source pad.
308  * @GST_PAD_SINK: the pad is a sink pad.
309  *
310  * The direction of a pad.
311  */
312 typedef enum {
313   GST_PAD_UNKNOWN,
314   GST_PAD_SRC,
315   GST_PAD_SINK
316 } GstPadDirection;
317
318 /**
319  * GstPadFlags:
320  * @GST_PAD_BLOCKED: is dataflow on a pad blocked
321  * @GST_PAD_FLUSHING: is pad refusing buffers
322  * @GST_PAD_IN_GETCAPS: GstPadGetCapsFunction() is running now
323  * @GST_PAD_IN_SETCAPS: GstPadSetCapsFunction() is running now
324  * @GST_PAD_FLAG_LAST: offset to define more flags
325  *
326  * Pad state flags
327  */
328 typedef enum {
329   GST_PAD_BLOCKED       = (GST_OBJECT_FLAG_LAST << 0),
330   GST_PAD_FLUSHING      = (GST_OBJECT_FLAG_LAST << 1),
331   GST_PAD_IN_GETCAPS    = (GST_OBJECT_FLAG_LAST << 2),
332   GST_PAD_IN_SETCAPS    = (GST_OBJECT_FLAG_LAST << 3),
333   /* padding */
334   GST_PAD_FLAG_LAST     = (GST_OBJECT_FLAG_LAST << 8)
335 } GstPadFlags;
336
337 /* FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h) */
338 typedef struct _GstPadTemplate GstPadTemplate;
339
340 struct _GstPad {
341   GstObject                     object;
342
343   gpointer                      element_private;
344
345   GstPadTemplate                *padtemplate;
346
347   /* direction cannot change after creating the pad */
348   GstPadDirection                direction;
349
350   /*< public >*/ /* with STREAM_LOCK */
351   /* streaming rec_lock */
352   GStaticRecMutex               *stream_rec_lock;
353   GstTask                       *task;
354   /*< public >*/ /* with PREROLL_LOCK */
355   GMutex                        *preroll_lock;
356   GCond                         *preroll_cond;
357
358   /*< public >*/ /* with LOCK */
359   /* block cond, mutex is from the object */
360   GCond                         *block_cond;
361   GstPadBlockCallback            block_callback;
362   gpointer                       block_data;
363
364   /* the pad capabilities */
365   GstCaps                       *caps;
366   GstPadGetCapsFunction         getcapsfunc;
367   GstPadSetCapsFunction         setcapsfunc;
368   GstPadAcceptCapsFunction       acceptcapsfunc;
369   GstPadFixateCapsFunction       fixatecapsfunc;
370
371   GstPadActivateFunction         activatefunc;
372   GstPadActivateModeFunction     activatepushfunc;
373   GstPadActivateModeFunction     activatepullfunc;
374
375   /* pad link */
376   GstPadLinkFunction             linkfunc;
377   GstPadUnlinkFunction           unlinkfunc;
378   GstPad                        *peer;
379
380   gpointer                       sched_private;
381
382   /* data transport functions */
383   GstPadChainFunction            chainfunc;
384   GstPadCheckGetRangeFunction    checkgetrangefunc;
385   GstPadGetRangeFunction         getrangefunc;
386   GstPadEventFunction            eventfunc;
387
388   GstActivateMode                mode;
389
390   /* generic query method */
391   GstPadQueryTypeFunction        querytypefunc;
392   GstPadQueryFunction            queryfunc;
393
394   /* internal links */
395   GstPadIntLinkFunction          intlinkfunc;
396
397   GstPadBufferAllocFunction      bufferallocfunc;
398
399   /* whether to emit signals for have-data. counts number
400    * of handlers attached. */
401   gint                           do_buffer_signals;
402   gint                           do_event_signals;
403
404   /*< private >*/
405   gpointer _gst_reserved[GST_PADDING];
406 };
407
408 struct _GstPadClass {
409   GstObjectClass        parent_class;
410
411   /* signal callbacks */
412   void          (*linked)               (GstPad *pad, GstPad *peer);
413   void          (*unlinked)             (GstPad *pad, GstPad *peer);
414   void          (*request_link)         (GstPad *pad);
415   gboolean      (*have_data)            (GstPad *pad, GstMiniObject *data);
416
417   /*< private >*/
418   gpointer _gst_reserved[GST_PADDING];
419 };
420
421
422 /***** helper macros *****/
423 /* GstPad */
424 #define GST_PAD_NAME(pad)               (GST_OBJECT_NAME(pad))
425 #define GST_PAD_PARENT(pad)             (GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad)))
426 #define GST_PAD_ELEMENT_PRIVATE(pad)    (GST_PAD_CAST(pad)->element_private)
427 #define GST_PAD_PAD_TEMPLATE(pad)       (GST_PAD_CAST(pad)->padtemplate)
428 #define GST_PAD_DIRECTION(pad)          (GST_PAD_CAST(pad)->direction)
429 #define GST_PAD_TASK(pad)               (GST_PAD_CAST(pad)->task)
430 #define GST_PAD_ACTIVATE_MODE(pad)      (GST_PAD_CAST(pad)->mode)
431
432 #define GST_PAD_ACTIVATEFUNC(pad)       (GST_PAD_CAST(pad)->activatefunc)
433 #define GST_PAD_ACTIVATEPUSHFUNC(pad)   (GST_PAD_CAST(pad)->activatepushfunc)
434 #define GST_PAD_ACTIVATEPULLFUNC(pad)   (GST_PAD_CAST(pad)->activatepullfunc)
435 #define GST_PAD_CHAINFUNC(pad)          (GST_PAD_CAST(pad)->chainfunc)
436 #define GST_PAD_CHECKGETRANGEFUNC(pad)  (GST_PAD_CAST(pad)->checkgetrangefunc)
437 #define GST_PAD_GETRANGEFUNC(pad)       (GST_PAD_CAST(pad)->getrangefunc)
438 #define GST_PAD_EVENTFUNC(pad)          (GST_PAD_CAST(pad)->eventfunc)
439 #define GST_PAD_QUERYTYPEFUNC(pad)      (GST_PAD_CAST(pad)->querytypefunc)
440 #define GST_PAD_QUERYFUNC(pad)          (GST_PAD_CAST(pad)->queryfunc)
441 #define GST_PAD_INTLINKFUNC(pad)        (GST_PAD_CAST(pad)->intlinkfunc)
442
443 #define GST_PAD_PEER(pad)               (GST_PAD_CAST(pad)->peer)
444 #define GST_PAD_LINKFUNC(pad)           (GST_PAD_CAST(pad)->linkfunc)
445 #define GST_PAD_UNLINKFUNC(pad)         (GST_PAD_CAST(pad)->unlinkfunc)
446
447 #define GST_PAD_CAPS(pad)               (GST_PAD_CAST(pad)->caps)
448 #define GST_PAD_GETCAPSFUNC(pad)        (GST_PAD_CAST(pad)->getcapsfunc)
449 #define GST_PAD_SETCAPSFUNC(pad)        (GST_PAD_CAST(pad)->setcapsfunc)
450 #define GST_PAD_ACCEPTCAPSFUNC(pad)     (GST_PAD_CAST(pad)->acceptcapsfunc)
451 #define GST_PAD_FIXATECAPSFUNC(pad)     (GST_PAD_CAST(pad)->fixatecapsfunc)
452
453 #define GST_PAD_BUFFERALLOCFUNC(pad)    (GST_PAD_CAST(pad)->bufferallocfunc)
454
455 #define GST_PAD_DO_BUFFER_SIGNALS(pad)  (GST_PAD_CAST(pad)->do_buffer_signals)
456 #define GST_PAD_DO_EVENT_SIGNALS(pad)   (GST_PAD_CAST(pad)->do_event_signals)
457
458 #define GST_PAD_IS_LINKED(pad)          (GST_PAD_PEER(pad) != NULL)
459 #define GST_PAD_IS_BLOCKED(pad)         (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED))
460 #define GST_PAD_IS_FLUSHING(pad)        (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING))
461 #define GST_PAD_IS_IN_GETCAPS(pad)      (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS))
462 #define GST_PAD_IS_IN_SETCAPS(pad)      (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS))
463 #define GST_PAD_IS_SRC(pad)             (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
464 #define GST_PAD_IS_SINK(pad)            (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
465
466 #define GST_PAD_SET_FLUSHING(pad)       (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLUSHING))
467 #define GST_PAD_UNSET_FLUSHING(pad)     (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLUSHING))
468
469 #define GST_STREAM_GET_LOCK(pad)        (GST_PAD_CAST(pad)->stream_rec_lock)
470 #define GST_STREAM_LOCK(pad)            (g_static_rec_mutex_lock(GST_STREAM_GET_LOCK(pad)))
471 #define GST_STREAM_TRYLOCK(pad)         (g_static_rec_mutex_trylock(GST_STREAM_GET_LOCK(pad)))
472 #define GST_STREAM_UNLOCK(pad)          (g_static_rec_mutex_unlock(GST_STREAM_GET_LOCK(pad)))
473 #define GST_STREAM_UNLOCK_FULL(pad)     (g_static_rec_mutex_unlock_full(GST_STREAM_GET_LOCK(pad)))
474 #define GST_STREAM_LOCK_FULL(pad,t)     (g_static_rec_mutex_lock_full(GST_STREAM_GET_LOCK(pad), t))
475
476 #define GST_PREROLL_GET_LOCK(pad)       (GST_PAD_CAST(pad)->preroll_lock)
477 #define GST_PREROLL_LOCK(pad)           (g_mutex_lock(GST_PREROLL_GET_LOCK(pad)))
478 #define GST_PREROLL_TRYLOCK(pad)        (g_mutex_trylock(GST_PREROLL_GET_LOCK(pad)))
479 #define GST_PREROLL_UNLOCK(pad)         (g_mutex_unlock(GST_PREROLL_GET_LOCK(pad)))
480 #define GST_PREROLL_GET_COND(pad)       (GST_PAD_CAST(pad)->preroll_cond)
481 #define GST_PREROLL_WAIT(pad)           g_cond_wait (GST_PREROLL_GET_COND (pad), GST_PREROLL_GET_LOCK (pad))
482 #define GST_PREROLL_TIMED_WAIT(pad, timeval) g_cond_timed_wait (GST_PREROLL_GET_COND (pad), GST_PREROLL_GET_LOCK (pad),\
483                                              timeval)
484 #define GST_PREROLL_SIGNAL(pad)         g_cond_signal (GST_PREROLL_GET_COND (pad));
485 #define GST_PREROLL_BROADCAST(pad)      g_cond_broadcast (GST_PREROLL_GET_COND (pad));
486
487 #define GST_PAD_BLOCK_GET_COND(pad)     (GST_PAD_CAST(pad)->block_cond)
488 #define GST_PAD_BLOCK_WAIT(pad)         (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad)))
489 #define GST_PAD_BLOCK_SIGNAL(pad)       (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad)))
490
491 /* FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h) */
492 #include <gst/gstpadtemplate.h>
493
494 GType                   gst_pad_get_type                        (void);
495
496 /* creating pads */
497 GstPad*                 gst_pad_new                             (const gchar *name, GstPadDirection direction);
498 GstPad*                 gst_pad_new_from_template               (GstPadTemplate *templ, const gchar *name);
499 GstPad*                 gst_pad_new_from_static_template        (GstStaticPadTemplate *templ, const gchar *name);
500
501
502 /**
503  * gst_pad_get_name:
504  * @pad: the pad to get the name from
505  *
506  * Get a copy of the name of the pad. g_free() after usage.
507  *
508  * MT safe.
509  */
510 #define gst_pad_get_name(pad) gst_object_get_name (GST_OBJECT_CAST (pad))
511 /**
512  * gst_pad_get_parent:
513  * @pad: the pad to get the parent of
514  *
515  * Get the parent of @pad. This function increases the refcount
516  * of the parent object so you should gst_object_unref() it after usage.
517  * Can return NULL if the pad did not have a parent.
518  *
519  * MT safe.
520  */
521 #define gst_pad_get_parent(pad) gst_object_get_parent (GST_OBJECT_CAST (pad))
522
523 GstPadDirection         gst_pad_get_direction                   (GstPad *pad);
524
525 gboolean                gst_pad_set_active                      (GstPad *pad, gboolean active);
526 gboolean                gst_pad_is_active                       (GstPad *pad);
527 gboolean                gst_pad_activate_pull                   (GstPad *pad, gboolean active);
528 gboolean                gst_pad_activate_push                   (GstPad *pad, gboolean active);
529
530 gboolean                gst_pad_set_blocked                     (GstPad *pad, gboolean blocked);
531 gboolean                gst_pad_set_blocked_async               (GstPad *pad, gboolean blocked,
532                                                                  GstPadBlockCallback callback, gpointer user_data);
533 gboolean                gst_pad_is_blocked                      (GstPad *pad);
534
535 void                    gst_pad_set_element_private             (GstPad *pad, gpointer priv);
536 gpointer                gst_pad_get_element_private             (GstPad *pad);
537
538 GstPadTemplate*         gst_pad_get_pad_template                (GstPad *pad);
539
540 void                    gst_pad_set_bufferalloc_function        (GstPad *pad, GstPadBufferAllocFunction bufalloc);
541 GstFlowReturn           gst_pad_alloc_buffer                    (GstPad *pad, guint64 offset, gint size,
542                                                                  GstCaps *caps, GstBuffer **buf);
543
544 /* data passing setup functions */
545 void                    gst_pad_set_activate_function           (GstPad *pad, GstPadActivateFunction activate);
546 void                    gst_pad_set_activatepull_function       (GstPad *pad, GstPadActivateModeFunction activatepull);
547 void                    gst_pad_set_activatepush_function       (GstPad *pad, GstPadActivateModeFunction activatepush);
548 void                    gst_pad_set_chain_function              (GstPad *pad, GstPadChainFunction chain);
549 void                    gst_pad_set_getrange_function           (GstPad *pad, GstPadGetRangeFunction get);
550 void                    gst_pad_set_checkgetrange_function      (GstPad *pad, GstPadCheckGetRangeFunction check);
551 void                    gst_pad_set_event_function              (GstPad *pad, GstPadEventFunction event);
552
553 /* pad links */
554 void                    gst_pad_set_link_function               (GstPad *pad, GstPadLinkFunction link);
555 void                    gst_pad_set_unlink_function             (GstPad *pad, GstPadUnlinkFunction unlink);
556
557 GstPadLinkReturn        gst_pad_link                            (GstPad *srcpad, GstPad *sinkpad);
558 gboolean                gst_pad_unlink                          (GstPad *srcpad, GstPad *sinkpad);
559 gboolean                gst_pad_is_linked                       (GstPad *pad);
560
561 GstPad*                 gst_pad_get_peer                        (GstPad *pad);
562
563 /* capsnego functions */
564 void                    gst_pad_set_getcaps_function            (GstPad *pad, GstPadGetCapsFunction getcaps);
565 void                    gst_pad_set_acceptcaps_function         (GstPad *pad, GstPadAcceptCapsFunction acceptcaps);
566 void                    gst_pad_set_fixatecaps_function         (GstPad *pad, GstPadFixateCapsFunction fixatecaps);
567 void                    gst_pad_set_setcaps_function            (GstPad *pad, GstPadSetCapsFunction setcaps);
568
569 G_CONST_RETURN GstCaps* gst_pad_get_pad_template_caps           (GstPad *pad);
570
571 /* capsnego function for connected/unconnected pads */
572 GstCaps *               gst_pad_get_caps                        (GstPad * pad);
573 void                    gst_pad_fixate_caps                     (GstPad * pad, GstCaps *caps);
574 gboolean                gst_pad_accept_caps                     (GstPad * pad, GstCaps *caps);
575 gboolean                gst_pad_set_caps                        (GstPad * pad, GstCaps *caps);
576
577 GstCaps *               gst_pad_peer_get_caps                   (GstPad * pad);
578 gboolean                gst_pad_peer_accept_caps                (GstPad * pad, GstCaps *caps);
579
580 /* capsnego for connected pads */
581 GstCaps *               gst_pad_get_allowed_caps                (GstPad * srcpad);
582 GstCaps *               gst_pad_get_negotiated_caps             (GstPad * pad);
583
584 /* data passing functions to peer */
585 GstFlowReturn           gst_pad_push                            (GstPad *pad, GstBuffer *buffer);
586 gboolean                gst_pad_check_pull_range                (GstPad *pad);
587 GstFlowReturn           gst_pad_pull_range                      (GstPad *pad, guint64 offset, guint size,
588                                                                  GstBuffer **buffer);
589 gboolean                gst_pad_push_event                      (GstPad *pad, GstEvent *event);
590 gboolean                gst_pad_event_default                   (GstPad *pad, GstEvent *event);
591
592 /* data passing functions on pad */
593 GstFlowReturn           gst_pad_chain                           (GstPad *pad, GstBuffer *buffer);
594 GstFlowReturn           gst_pad_get_range                       (GstPad *pad, guint64 offset, guint size,
595                                                                  GstBuffer **buffer);
596 gboolean                gst_pad_send_event                      (GstPad *pad, GstEvent *event);
597
598 /* pad tasks */
599 gboolean                gst_pad_start_task                      (GstPad *pad, GstTaskFunction func,
600                                                                  gpointer data);
601 gboolean                gst_pad_pause_task                      (GstPad *pad);
602 gboolean                gst_pad_stop_task                       (GstPad *pad);
603
604 /* internal links */
605 void                    gst_pad_set_internal_link_function      (GstPad *pad, GstPadIntLinkFunction intlink);
606 GList*                  gst_pad_get_internal_links              (GstPad *pad);
607 GList*                  gst_pad_get_internal_links_default      (GstPad *pad);
608
609 /* generic query function */
610 void                    gst_pad_set_query_type_function         (GstPad *pad, GstPadQueryTypeFunction type_func);
611 G_CONST_RETURN GstQueryType*
612                         gst_pad_get_query_types                 (GstPad *pad);
613 G_CONST_RETURN GstQueryType*
614                         gst_pad_get_query_types_default         (GstPad *pad);
615
616 gboolean                gst_pad_query                           (GstPad *pad, GstQuery *query);
617 void                    gst_pad_set_query_function              (GstPad *pad, GstPadQueryFunction query);
618 gboolean                gst_pad_query_default                   (GstPad *pad, GstQuery *query);
619
620 /* misc helper functions */
621 gboolean                gst_pad_dispatcher                      (GstPad *pad, GstPadDispatcherFunction dispatch,
622                                                                  gpointer data);
623
624 #ifndef GST_DISABLE_LOADSAVE
625 void                    gst_pad_load_and_link                   (xmlNodePtr self, GstObject *parent);
626 #endif
627
628 G_END_DECLS
629
630 #endif /* __GST_PAD_H__ */