check/gst/gstevent.c (create_custom_events): Check that
[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
49 typedef struct _GstPad GstPad;
50 typedef struct _GstPadClass GstPadClass;
51
52 /**
53  * GstPadLinkReturn:
54  * @GST_PAD_LINK_OK             : link succeeded
55  * @GST_PAD_LINK_WRONG_HIERARCHY: pads have no common grandparent
56  * @GST_PAD_LINK_WAS_LINKED     : pad was already linked
57  * @GST_PAD_LINK_WRONG_DIRECTION: pads have wrong direction
58  * @GST_PAD_LINK_NOFORMAT       : pads do not have common format
59  * @GST_PAD_LINK_NOSCHED        : pads cannot cooperate in scheduling
60  * @GST_PAD_LINK_REFUSED        : refused for some reason
61  */
62 typedef enum {
63   GST_PAD_LINK_OK               =  0,
64   GST_PAD_LINK_WRONG_HIERARCHY  = -1,
65   GST_PAD_LINK_WAS_LINKED       = -2,
66   GST_PAD_LINK_WRONG_DIRECTION  = -3,
67   GST_PAD_LINK_NOFORMAT         = -4,
68   GST_PAD_LINK_NOSCHED          = -5,
69   GST_PAD_LINK_REFUSED          = -6,
70 } GstPadLinkReturn;
71
72 /**
73  * GST_PAD_LINK_FAILED:
74  * @ret: the #GstPadLinkReturn value
75  *
76  * Macro to test if the given #GstPadLinkReturn value indicates a failed
77  * link step.
78  */
79 #define GST_PAD_LINK_FAILED(ret) ((ret) < GST_PAD_LINK_OK)
80
81 /**
82  * GST_PAD_LINK_SUCCESSFUL:
83  * @ret: the #GstPadLinkReturn value
84  *
85  * Macro to test if the given #GstPadLinkReturn value indicates a successful
86  * link step.
87  */
88 #define GST_PAD_LINK_SUCCESSFUL(ret) ((ret) >= GST_PAD_LINK_OK)
89
90 /**
91  * GstFlowReturn:
92  * @GST_FLOW_RESEND:             Resend buffer, possibly with new caps.
93  * @GST_FLOW_OK:                 Data passing was ok.
94  * @GST_FLOW_NOT_LINKED:         Pad is not linked.
95  * @GST_FLOW_WRONG_STATE:        Pad is in wrong state.
96  * @GST_FLOW_UNEXPECTED:         Did not expect anything, like after EOS.
97  * @GST_FLOW_NOT_NEGOTIATED:     Pad is not negotiated.
98  * @GST_FLOW_ERROR:              Some (fatal) error occured.
99  * @GST_FLOW_NOT_SUPPORTED:      This operation is not supported.
100  *
101  * The result of passing data to a linked pad.
102  */
103 typedef enum {
104   GST_FLOW_RESEND         =  1,
105   GST_FLOW_OK             =  0,
106   /* expected failures */
107   GST_FLOW_NOT_LINKED     = -1,
108   GST_FLOW_WRONG_STATE    = -2,
109   /* error cases */
110   GST_FLOW_UNEXPECTED     = -3,
111   GST_FLOW_NOT_NEGOTIATED = -4,
112   GST_FLOW_ERROR          = -5,
113   GST_FLOW_NOT_SUPPORTED  = -6
114 } GstFlowReturn;
115
116 /**
117  * GST_FLOW_IS_FATAL:
118  * @ret: a #GstFlowReturn value
119  *
120  * Macro to test if the given #GstFlowReturn value indicates a fatal
121  * error. This macro is mainly used in elements to decide when an error
122  * message should be posted on the bus.
123  */
124 #define GST_FLOW_IS_FATAL(ret) ((ret) <= GST_FLOW_UNEXPECTED)
125
126 G_CONST_RETURN gchar*   gst_flow_get_name       (GstFlowReturn ret);
127 GQuark                  gst_flow_to_quark       (GstFlowReturn ret);
128
129 /**
130  * GstActivateMode:
131  * @GST_ACTIVATE_NONE:           Pad will not handle dataflow
132  * @GST_ACTIVATE_PUSH:           Pad handles dataflow in downstream push mode
133  * @GST_ACTIVATE_PULL:           Pad handles dataflow in upstream pull mode
134  *
135  * The status of a GstPad. After activating a pad, which usually happens when the
136  * parent element goes from READY to PAUSED, the GstActivateMode defines if the
137  * pad operates in push or pull mode.
138  */
139 typedef enum {
140   GST_ACTIVATE_NONE,
141   GST_ACTIVATE_PUSH,
142   GST_ACTIVATE_PULL,
143 } GstActivateMode;
144
145 /**
146  * GST_PAD_MODE_ACTIVATE:
147  * @mode: a #GstActivateMode
148  *
149  * Macro to test if the given #GstActivateMode value indicates that datapassing
150  * is possible or not.
151  */
152 #define GST_PAD_MODE_ACTIVATE(mode) ((mode) != GST_ACTIVATE_NONE)
153
154 /* pad states */
155 typedef gboolean                (*GstPadActivateFunction)       (GstPad *pad);
156 typedef gboolean                (*GstPadActivateModeFunction)   (GstPad *pad, gboolean active);
157
158
159 /* data passing */
160 /**
161  * GstPadChainFunction:
162  * @pad: the #GstPad that performed the chain.
163  * @buffer: the #GstBuffer that is chained.
164  *
165  * A function that will be called on sinkpads when chaining buffers.
166  *
167  * Returns: GST_FLOW_OK for success
168  */
169 typedef GstFlowReturn           (*GstPadChainFunction)          (GstPad *pad, GstBuffer *buffer);
170 /**
171  * GstPadGetRangeFunction:
172  * @pad: the #GstPad to perform the getrange on.
173  * @offset: the offset of the range
174  * @length: the length of the range
175  * @buffer: a memory location to hold the result buffer
176  *
177  * This function will be called on sourcepads when a peer element
178  * request a buffer at the specified offset and length. If this function
179  * returns GST_FLOW_OK, the result buffer will be stored in @buffer. The 
180  * contents of @buffer is invalid for any other return value.
181  *
182  * Returns: GST_FLOW_OK for success
183  */
184 typedef GstFlowReturn           (*GstPadGetRangeFunction)       (GstPad *pad, guint64 offset,
185                                                                  guint length, GstBuffer **buffer);
186
187 /**
188  * GstPadEventFunction:
189  * @pad: the #GstPad to handle the event.
190  * @event: the #GstEvent to handle.
191  *
192  * Function signature to handle an event for the pad.
193  *
194  * Returns: TRUE if the pad could handle the event.
195  */
196 typedef gboolean                (*GstPadEventFunction)          (GstPad *pad, GstEvent *event);
197
198
199 /* deprecate me, check range should use seeking query */
200 typedef gboolean                (*GstPadCheckGetRangeFunction)  (GstPad *pad);
201
202
203 /* internal links */
204 /**
205  * GstPadIntLinkFunction:
206  * @pad: The #GstPad to query.
207  *
208  * The signature of the internal pad link function.
209  *
210  * Returns: a newly allocated #GList of pads that are linked to the given pad on
211  *  the inside of the parent element.
212  *  The caller must call g_list_free() on it after use.
213  */
214 typedef GList*                  (*GstPadIntLinkFunction)        (GstPad *pad);
215
216
217 /* generic query function */
218 /**
219  * GstPadQueryTypeFunction:
220  * @pad: a #GstPad to query
221  *
222  * The signature of the query types function.
223  *
224  * Returns: a constant array of query types
225  */
226 typedef const GstQueryType*     (*GstPadQueryTypeFunction)      (GstPad *pad);
227
228 /**
229  * GstPadQueryFunction:
230  * @pad: the #GstPad to query.
231  * @query: the #GstQuery object to execute
232  *
233  * The signature of the query function.
234  *
235  * Returns: TRUE if the query could be performed.
236  */
237 typedef gboolean                (*GstPadQueryFunction)          (GstPad *pad, GstQuery *query);
238
239
240 /* linking */
241 /**
242  * GstPadLinkFunction
243  * @pad: the #GstPad that is linked.
244  * @peer: the peer #GstPad of the link
245  *
246  * Function signature to handle a new link on the pad.
247  *
248  * Returns: the result of the link with the specified peer.
249  */
250 typedef GstPadLinkReturn        (*GstPadLinkFunction)           (GstPad *pad, GstPad *peer);
251 /**
252  * GstPadUnlinkFunction
253  * @pad: the #GstPad that is linked.
254  *
255  * Function signature to handle a unlinking the pad prom its peer.
256  */
257 typedef void                    (*GstPadUnlinkFunction)         (GstPad *pad);
258
259
260 /* caps nego */
261 /**
262  * GstPadGetCapsFunction:
263  * @pad: the #GstPad to get the capabilities of.
264  *
265  * Returns a copy of the capabilities of the specified pad. By default this
266  * function will return the pad template capabilities, but can optionally
267  * be overridden.
268  *
269  * Returns: a newly allocated copy #GstCaps of the pad.
270  */
271 typedef GstCaps*                (*GstPadGetCapsFunction)        (GstPad *pad);
272 typedef gboolean                (*GstPadSetCapsFunction)        (GstPad *pad, GstCaps *caps);
273 typedef gboolean                (*GstPadAcceptCapsFunction)     (GstPad *pad, GstCaps *caps);
274 typedef void                    (*GstPadFixateCapsFunction)     (GstPad *pad, GstCaps *caps);
275 typedef GstFlowReturn           (*GstPadBufferAllocFunction)    (GstPad *pad, guint64 offset, guint size,
276                                                                  GstCaps *caps, GstBuffer **buf);
277
278 /* misc */
279 /**
280  * GstPadDispatcherFunction:
281  * @pad: the #GstPad that is dispatched.
282  * @data: the gpointer to optional user data.
283  *
284  * A dispatcher function is called for all internally linked pads, see
285  * gst_pad_dispatcher().
286  *
287  * Returns: TRUE if the dispatching procedure has to be stopped.
288  */
289 typedef gboolean                (*GstPadDispatcherFunction)     (GstPad *pad, gpointer data);
290
291 /**
292  * GstPadBlockCallback:
293  * @pad: the #GstPad that is blockend or unblocked.
294  * @blocked: blocking state for the pad
295  * @user_data: the gpointer to optional user data.
296  *
297  * Callback used by gst_pad_set_blocked_async(). Gets called when the blocking
298  * operation succeeds.
299  */
300 typedef void                    (*GstPadBlockCallback)          (GstPad *pad, gboolean blocked, gpointer user_data);
301
302 /**
303  * GstPadDirection:
304  * @GST_PAD_UNKNOWN: direction is unknown.
305  * @GST_PAD_SRC: the pad is a source pad.
306  * @GST_PAD_SINK: the pad is a sink pad.
307  *
308  * The direction of a pad.
309  */
310 typedef enum {
311   GST_PAD_UNKNOWN,
312   GST_PAD_SRC,
313   GST_PAD_SINK
314 } GstPadDirection;
315
316 /**
317  * GstPadFlags:
318  * @GST_PAD_BLOCKED: is dataflow on a pad blocked
319  * @GST_PAD_FLUSHING: is pad refusing buffers
320  * @GST_PAD_IN_GETCAPS: GstPadGetCapsFunction() is running now
321  * @GST_PAD_IN_SETCAPS: GstPadSetCapsFunction() is running now
322  * @GST_PAD_FLAG_LAST: offset to define more flags
323  *
324  * Pad state flags
325  */
326 typedef enum {
327   GST_PAD_BLOCKED       = (GST_OBJECT_FLAG_LAST << 0),
328   GST_PAD_FLUSHING      = (GST_OBJECT_FLAG_LAST << 1),
329   GST_PAD_IN_GETCAPS    = (GST_OBJECT_FLAG_LAST << 2),
330   GST_PAD_IN_SETCAPS    = (GST_OBJECT_FLAG_LAST << 3),
331   /* padding */
332   GST_PAD_FLAG_LAST     = (GST_OBJECT_FLAG_LAST << 8)
333 } GstPadFlags;
334
335 /* FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h) */
336 typedef struct _GstPadTemplate GstPadTemplate;
337
338 struct _GstPad {
339   GstObject                     object;
340
341   gpointer                      element_private;
342
343   GstPadTemplate                *padtemplate;
344
345   /* direction cannot change after creating the pad */
346   GstPadDirection                direction;
347
348   /*< public >*/ /* with STREAM_LOCK */
349   /* streaming rec_lock */
350   GStaticRecMutex               *stream_rec_lock;
351   GstTask                       *task;
352   /*< public >*/ /* with PREROLL_LOCK */
353   GMutex                        *preroll_lock;
354   GCond                         *preroll_cond;
355
356   /*< public >*/ /* with LOCK */
357   /* block cond, mutex is from the object */
358   GCond                         *block_cond;
359   GstPadBlockCallback            block_callback;
360   gpointer                       block_data;
361
362   /* the pad capabilities */
363   GstCaps                       *caps;
364   GstPadGetCapsFunction         getcapsfunc;
365   GstPadSetCapsFunction         setcapsfunc;
366   GstPadAcceptCapsFunction       acceptcapsfunc;
367   GstPadFixateCapsFunction       fixatecapsfunc;
368
369   GstPadActivateFunction         activatefunc;
370   GstPadActivateModeFunction     activatepushfunc;
371   GstPadActivateModeFunction     activatepullfunc;
372
373   /* pad link */
374   GstPadLinkFunction             linkfunc;
375   GstPadUnlinkFunction           unlinkfunc;
376   GstPad                        *peer;
377
378   gpointer                       sched_private;
379
380   /* data transport functions */
381   GstPadChainFunction            chainfunc;
382   GstPadCheckGetRangeFunction    checkgetrangefunc;
383   GstPadGetRangeFunction         getrangefunc;
384   GstPadEventFunction            eventfunc;
385
386   GstActivateMode                mode;
387
388   /* generic query method */
389   GstPadQueryTypeFunction        querytypefunc;
390   GstPadQueryFunction            queryfunc;
391
392   /* internal links */
393   GstPadIntLinkFunction          intlinkfunc;
394
395   GstPadBufferAllocFunction      bufferallocfunc;
396
397   /* whether to emit signals for have-data. counts number
398    * of handlers attached. */
399   gint                           do_buffer_signals;
400   gint                           do_event_signals;
401
402   /*< private >*/
403   gpointer _gst_reserved[GST_PADDING];
404 };
405
406 struct _GstPadClass {
407   GstObjectClass        parent_class;
408
409   /* signal callbacks */
410   void          (*linked)               (GstPad *pad, GstPad *peer);
411   void          (*unlinked)             (GstPad *pad, GstPad *peer);
412   void          (*request_link)         (GstPad *pad);
413   gboolean      (*have_data)            (GstPad *pad, GstMiniObject *data);
414
415   /*< private >*/
416   gpointer _gst_reserved[GST_PADDING];
417 };
418
419
420 /***** helper macros *****/
421 /* GstPad */
422 #define GST_PAD_NAME(pad)               (GST_OBJECT_NAME(pad))
423 #define GST_PAD_PARENT(pad)             (GST_ELEMENT_CAST(GST_OBJECT_PARENT(pad)))
424 #define GST_PAD_ELEMENT_PRIVATE(pad)    (GST_PAD_CAST(pad)->element_private)
425 #define GST_PAD_PAD_TEMPLATE(pad)       (GST_PAD_CAST(pad)->padtemplate)
426 #define GST_PAD_DIRECTION(pad)          (GST_PAD_CAST(pad)->direction)
427 #define GST_PAD_TASK(pad)               (GST_PAD_CAST(pad)->task)
428 #define GST_PAD_ACTIVATE_MODE(pad)      (GST_PAD_CAST(pad)->mode)
429
430 #define GST_PAD_ACTIVATEFUNC(pad)       (GST_PAD_CAST(pad)->activatefunc)
431 #define GST_PAD_ACTIVATEPUSHFUNC(pad)   (GST_PAD_CAST(pad)->activatepushfunc)
432 #define GST_PAD_ACTIVATEPULLFUNC(pad)   (GST_PAD_CAST(pad)->activatepullfunc)
433 #define GST_PAD_CHAINFUNC(pad)          (GST_PAD_CAST(pad)->chainfunc)
434 #define GST_PAD_CHECKGETRANGEFUNC(pad)  (GST_PAD_CAST(pad)->checkgetrangefunc)
435 #define GST_PAD_GETRANGEFUNC(pad)       (GST_PAD_CAST(pad)->getrangefunc)
436 #define GST_PAD_EVENTFUNC(pad)          (GST_PAD_CAST(pad)->eventfunc)
437 #define GST_PAD_QUERYTYPEFUNC(pad)      (GST_PAD_CAST(pad)->querytypefunc)
438 #define GST_PAD_QUERYFUNC(pad)          (GST_PAD_CAST(pad)->queryfunc)
439 #define GST_PAD_INTLINKFUNC(pad)        (GST_PAD_CAST(pad)->intlinkfunc)
440
441 #define GST_PAD_PEER(pad)               (GST_PAD_CAST(pad)->peer)
442 #define GST_PAD_LINKFUNC(pad)           (GST_PAD_CAST(pad)->linkfunc)
443 #define GST_PAD_UNLINKFUNC(pad)         (GST_PAD_CAST(pad)->unlinkfunc)
444
445 #define GST_PAD_CAPS(pad)               (GST_PAD_CAST(pad)->caps)
446 #define GST_PAD_GETCAPSFUNC(pad)        (GST_PAD_CAST(pad)->getcapsfunc)
447 #define GST_PAD_SETCAPSFUNC(pad)        (GST_PAD_CAST(pad)->setcapsfunc)
448 #define GST_PAD_ACCEPTCAPSFUNC(pad)     (GST_PAD_CAST(pad)->acceptcapsfunc)
449 #define GST_PAD_FIXATECAPSFUNC(pad)     (GST_PAD_CAST(pad)->fixatecapsfunc)
450
451 #define GST_PAD_BUFFERALLOCFUNC(pad)    (GST_PAD_CAST(pad)->bufferallocfunc)
452
453 #define GST_PAD_DO_BUFFER_SIGNALS(pad)  (GST_PAD_CAST(pad)->do_buffer_signals)
454 #define GST_PAD_DO_EVENT_SIGNALS(pad)   (GST_PAD_CAST(pad)->do_event_signals)
455
456 #define GST_PAD_IS_LINKED(pad)          (GST_PAD_PEER(pad) != NULL)
457 #define GST_PAD_IS_BLOCKED(pad)         (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_BLOCKED))
458 #define GST_PAD_IS_FLUSHING(pad)        (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLUSHING))
459 #define GST_PAD_IS_IN_GETCAPS(pad)      (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_GETCAPS))
460 #define GST_PAD_IS_IN_SETCAPS(pad)      (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_IN_SETCAPS))
461 #define GST_PAD_IS_SRC(pad)             (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
462 #define GST_PAD_IS_SINK(pad)            (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
463
464 #define GST_PAD_SET_FLUSHING(pad)       (GST_OBJECT_FLAG_SET (pad, GST_PAD_FLUSHING))
465 #define GST_PAD_UNSET_FLUSHING(pad)     (GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLUSHING))
466
467 #define GST_PAD_GET_STREAM_LOCK(pad)    (GST_PAD_CAST(pad)->stream_rec_lock)
468 #define GST_PAD_STREAM_LOCK(pad)        (g_static_rec_mutex_lock(GST_PAD_GET_STREAM_LOCK(pad)))
469 #define GST_PAD_STREAM_TRYLOCK(pad)     (g_static_rec_mutex_trylock(GST_PAD_GET_STREAM_LOCK(pad)))
470 #define GST_PAD_STREAM_UNLOCK(pad)      (g_static_rec_mutex_unlock(GST_PAD_GET_STREAM_LOCK(pad)))
471 #define GST_PAD_STREAM_UNLOCK_FULL(pad) (g_static_rec_mutex_unlock_full(GST_PAD_GET_STREAM_LOCK(pad)))
472 #define GST_PAD_STREAM_LOCK_FULL(pad,t) (g_static_rec_mutex_lock_full(GST_PAD_GET_STREAM_LOCK(pad), t))
473
474 #define GST_PAD_GET_PREROLL_LOCK(pad)   (GST_PAD_CAST(pad)->preroll_lock)
475 #define GST_PAD_PREROLL_LOCK(pad)       (g_mutex_lock(GST_PAD_GET_PREROLL_LOCK(pad)))
476 #define GST_PAD_PREROLL_TRYLOCK(pad)    (g_mutex_trylock(GST_PAD_GET_PREROLL_LOCK(pad)))
477 #define GST_PAD_PREROLL_UNLOCK(pad)     (g_mutex_unlock(GST_PAD_GET_PREROLL_LOCK(pad)))
478
479 #define GST_PAD_GET_PREROLL_COND(pad)   (GST_PAD_CAST(pad)->preroll_cond)
480 #define GST_PAD_PREROLL_WAIT(pad)       \
481     g_cond_wait (GST_PAD_GET_PREROLL_COND (pad), GST_PAD_GET_PREROLL_LOCK (pad))
482 #define GST_PAD_PREROLL_TIMED_WAIT(pad, timeval) \
483     g_cond_timed_wait (GST_PAD_GET_PREROLL_COND (pad), GST_PAD_GET_PREROLL_LOCK (pad), timeval)
484 #define GST_PAD_PREROLL_SIGNAL(pad)     g_cond_signal (GST_PAD_GET_PREROLL_COND (pad));
485 #define GST_PAD_PREROLL_BROADCAST(pad)  g_cond_broadcast (GST_PAD_GET_PREROLL_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__ */