2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wim.taymans@chello.be>
5 * gstpad.h: Header for GstPad object
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
27 #include <parser.h> // NOTE: This is xml-config's fault
29 #include <gst/gstobject.h>
30 #include <gst/gstbuffer.h>
31 #include <gst/cothreads.h>
32 #include <gst/gstcaps.h>
37 #endif /* __cplusplus */
40 #define GST_TYPE_PAD (gst_pad_get_type ())
41 #define GST_PAD(obj) (GTK_CHECK_CAST ((obj), GST_TYPE_PAD,GstPad))
42 #define GST_PAD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GST_TYPE_PAD,GstPadClass))
43 #define GST_IS_PAD(obj) (GTK_CHECK_TYPE ((obj), GST_TYPE_PAD))
44 #define GST_IS_PAD_CLASS(obj) (GTK_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD))
46 #define GST_TYPE_REAL_PAD (gst_real_pad_get_type ())
47 #define GST_REAL_PAD(obj) (GTK_CHECK_CAST ((obj), GST_TYPE_REAL_PAD,GstRealPad))
48 #define GST_REAL_PAD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GST_TYPE_REAL_PAD,GstRealPadClass))
49 #define GST_IS_REAL_PAD(obj) (GTK_CHECK_TYPE ((obj), GST_TYPE_REAL_PAD))
50 #define GST_IS_REAL_PAD_CLASS(obj) (GTK_CHECK_CLASS_TYPE ((klass), GST_TYPE_REAL_PAD))
52 #define GST_TYPE_GHOST_PAD (gst_ghost_pad_get_type ())
53 #define GST_GHOST_PAD(obj) (GTK_CHECK_CAST ((obj), GST_TYPE_GHOST_PAD,GstGhostPad))
54 #define GST_GHOST_PAD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GST_TYPE_GHOST_PAD,GstGhostPadClass))
55 #define GST_IS_GHOST_PAD(obj) (GTK_CHECK_TYPE ((obj), GST_TYPE_GHOST_PAD))
56 #define GST_IS_GHOST_PAD_CLASS(obj) (GTK_CHECK_CLASS_TYPE ((klass), GST_TYPE_GHOST_PAD))
59 typedef struct _GstPad GstPad;
60 typedef struct _GstPadClass GstPadClass;
61 typedef struct _GstRealPad GstRealPad;
62 typedef struct _GstRealPadClass GstRealPadClass;
63 typedef struct _GstGhostPad GstGhostPad;
64 typedef struct _GstGhostPadClass GstGhostPadClass;
65 typedef struct _GstPadTemplate GstPadTemplate;
66 typedef struct _GstPadTemplateClass GstPadTemplateClass;
69 /* this defines the functions used to chain buffers
70 * pad is the sink pad (so the same chain function can be used for N pads)
71 * buf is the buffer being passed */
72 typedef void (*GstPadChainFunction) (GstPad *pad,GstBuffer *buf);
73 typedef GstBuffer *(*GstPadGetFunction) (GstPad *pad);
74 typedef GstBuffer *(*GstPadGetRegionFunction) (GstPad *pad, gulong offset, gulong size);
75 typedef void (*GstPadQoSFunction) (GstPad *pad, glong qos_message);
77 typedef void (*GstPadPushFunction) (GstPad *pad, GstBuffer *buf);
78 typedef GstBuffer *(*GstPadPullFunction) (GstPad *pad);
79 typedef GstBuffer *(*GstPadPullRegionFunction) (GstPad *pad, gulong offset, gulong size);
81 typedef gboolean (*GstPadEOSFunction) (GstPad *pad);
90 GST_PAD_DISABLED = GST_OBJECT_FLAG_LAST,
93 GST_PAD_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4,
100 gpointer element_private;
103 GstPadTemplate *padtemplate; /* the template for this pad */
106 struct _GstPadClass {
107 GstObjectClass parent_class;
114 GstPadDirection direction;
116 cothread_state *threadstate;
122 GstPadChainFunction chainfunc;
123 GstPadGetFunction getfunc;
124 GstPadGetRegionFunction getregionfunc;
125 GstPadQoSFunction qosfunc;
126 GstPadEOSFunction eosfunc;
128 GstPadPushFunction pushfunc;
129 GstPadPullFunction pullfunc;
130 GstPadPullRegionFunction pullregionfunc;
135 struct _GstRealPadClass {
136 GstPadClass parent_class;
138 /* signal callbacks */
139 void (*set_active) (GstPad *pad, gboolean active);
140 void (*caps_changed) (GstPad *pad, GstCaps *newcaps);
141 void (*eos) (GstPad *pad);
144 struct _GstGhostPad {
150 struct _GstGhostPadClass {
151 GstPadClass parent_class;
155 /***** helper macros *****/
157 #define GST_PAD_NAME(pad) (((GstPad *)(pad))->name)
158 #define GST_PAD_ELEMENT_PRIVATE(pad) (((GstPad *)(pad))->element_private)
159 #define GST_PAD_PARENT(pad) (((GstPad *)(pad))->parent)
160 #define GST_PAD_PADTEMPLATE(pad) (((GstPad *)(pad))->padtemplate)
163 #define GST_RPAD_DIRECTION(pad) (((GstRealPad *)(pad))->direction)
164 #define GST_RPAD_CAPS(pad) (((GstRealPad *)(pad))->caps)
165 #define GST_RPAD_PEER(pad) (((GstRealPad *)(pad))->peer)
166 #define GST_RPAD_BUFPEN(pad) (((GstRealPad *)(pad))->bufpen)
167 #define GST_RPAD_CHAINFUNC(pad) (((GstRealPad *)(pad))->chainfunc)
168 #define GST_RPAD_GETFUNC(pad) (((GstRealPad *)(pad))->getfunc)
169 #define GST_RPAD_GETREGIONFUNC(pad) (((GstRealPad *)(pad))->getregionfunc)
170 #define GST_RPAD_PUSHFUNC(pad) (((GstRealPad *)(pad))->pushfunc)
171 #define GST_RPAD_PULLFUNC(pad) (((GstRealPad *)(pad))->pullfunc)
172 #define GST_RPAD_PULLREGIONFUNC(pad) (((GstRealPad *)(pad))->pullregionfunc)
173 #define GST_RPAD_QOSFUNC(pad) (((GstRealPad *)(pad))->qosfunc)
174 #define GST_RPAD_EOSFUNC(pad) (((GstRealPad *)(pad))->eosfunc)
177 #define GST_GPAD_REALPAD(pad) (((GstGhostPad *)(pad))->realpad)
180 #define GST_PAD_REALIZE(pad) (GST_IS_REAL_PAD(pad) ? ((GstRealPad *)(pad)) : GST_GPAD_REALPAD(pad))
181 #define GST_PAD_DIRECTION(pad) GST_RPAD_DIRECTION(GST_PAD_REALIZE(pad))
182 #define GST_PAD_CAPS(pad) GST_RPAD_CAPS(GST_PAD_REALIZE(pad))
183 #define GST_PAD_PEER(pad) GST_RPAD_PEER(GST_PAD_REALIZE(pad))
185 /* Some check functions (unused?) */
186 #define GST_PAD_CONNECTED(pad) (GST_IS_REAL_PAD(pad) && GST_REAL_PAD(pad)->peer != NULL)
187 #define GST_PAD_CAN_PULL(pad) (GST_IS_REAL_PAD(pad) && GST_REAL_PAD(pad)->pullfunc != NULL)
190 /***** PadTemplate *****/
191 #define GST_TYPE_PADTEMPLATE (gst_padtemplate_get_type ())
192 #define GST_PADTEMPLATE(obj) (GTK_CHECK_CAST ((obj), GST_TYPE_PADTEMPLATE,GstPad))
193 #define GST_PADTEMPLATE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GST_TYPE_PADTEMPLATE,GstPadClass))
194 #define GST_IS_PADTEMPLATE(obj) (GTK_CHECK_TYPE ((obj), GST_TYPE_PADTEMPLATE))
195 #define GST_IS_PADTEMPLATE_CLASS(obj) (GTK_CHECK_CLASS_TYPE ((klass), GST_TYPE_PADTEMPLATE))
203 struct _GstPadTemplate {
206 gchar *name_template;
207 GstPadDirection direction;
208 GstPadPresence presence;
212 struct _GstPadTemplateClass {
213 GstObjectClass parent_class;
215 /* signal callbacks */
216 void (*pad_created) (GstPadTemplate *templ, GstPad *pad);
221 typedef gpointer GstPadFactoryEntry;
222 typedef GstPadFactoryEntry GstPadFactory[];
224 #define GST_PAD_FACTORY_ALWAYS GINT_TO_POINTER(GST_PAD_ALWAYS)
225 #define GST_PAD_FACTORY_SOMETIMES GINT_TO_POINTER(GST_PAD_SOMETIMES)
226 #define GST_PAD_FACTORY_REQUEST GINT_TO_POINTER(GST_PAD_REQUEST)
228 #define GST_PAD_FACTORY_SRC GINT_TO_POINTER(GST_PAD_SRC)
229 #define GST_PAD_FACTORY_SINK GINT_TO_POINTER(GST_PAD_SINK)
231 #define GST_PAD_FACTORY_CAPS(a...) GINT_TO_POINTER(1),##a,NULL
234 GtkType gst_pad_get_type (void);
235 GtkType gst_real_pad_get_type (void);
236 GtkType gst_ghost_pad_get_type (void);
238 GstPad* gst_pad_new (gchar *name, GstPadDirection direction);
239 #define gst_pad_destroy(pad) gst_object_destroy (GST_OBJECT (pad))
240 GstPad* gst_pad_new_from_template (GstPadTemplate *templ, gchar *name);
242 GstPadDirection gst_pad_get_direction (GstPad *pad);
244 void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
245 void gst_pad_set_get_function (GstPad *pad, GstPadGetFunction get);
246 void gst_pad_set_getregion_function (GstPad *pad, GstPadGetRegionFunction getregion);
247 void gst_pad_set_qos_function (GstPad *pad, GstPadQoSFunction qos);
248 void gst_pad_set_eos_function (GstPad *pad, GstPadEOSFunction eos);
250 void gst_pad_set_caps_list (GstPad *pad, GList *caps);
251 GList* gst_pad_get_caps_list (GstPad *pad);
252 GstCaps* gst_pad_get_caps_by_name (GstPad *pad, gchar *name);
253 gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad);
255 void gst_pad_set_name (GstPad *pad, const gchar *name);
256 const gchar* gst_pad_get_name (GstPad *pad);
258 void gst_pad_set_element_private (GstPad *pad, gpointer priv);
259 gpointer gst_pad_get_element_private (GstPad *pad);
261 void gst_pad_set_parent (GstPad *pad, GstObject *parent);
262 GstObject* gst_pad_get_parent (GstPad *pad);
263 void gst_pad_add_ghost_pad (GstPad *pad, GstPad *ghostpad);
264 void gst_pad_remove_ghost_pad (GstPad *pad, GstPad *ghostpad);
265 GList* gst_pad_get_ghost_pad_list (GstPad *pad);
267 GstPad* gst_pad_get_peer (GstPad *pad);
269 void gst_pad_connect (GstPad *srcpad, GstPad *sinkpad);
270 void gst_pad_disconnect (GstPad *srcpad, GstPad *sinkpad);
273 void gst_pad_push (GstPad *pad, GstBuffer *buffer);
275 #define gst_pad_push(pad,buf) G_STMT_START{ \
276 if ((pad)->peer->pushfunc) ((pad)->peer->pushfunc)((pad)->peer,(buf)); \
280 GstBuffer* gst_pad_pull (GstPad *pad);
281 GstBuffer* gst_pad_pull_region (GstPad *pad, gulong offset, gulong size);
283 #define gst_pad_pull(pad) \
284 (((pad)->peer->pullfunc) ? ((pad)->peer->pullfunc)((pad)->peer) : NULL)
285 #define gst_pad_pullregion(pad,offset,size) \
286 (((pad)->peer->pullregionfunc) ? ((pad)->peer->pullregionfunc)((pad)->peer,(offset),(size)) : NULL)
289 GstPad * gst_pad_select (GstPad *nextpad, ...);
291 #define gst_pad_eos(pad) (GST_RPAD_EOSFUNC(GST_RPAD_PEER(pad))(GST_PAD(GST_RPAD_PEER(pad))))
292 gboolean gst_pad_set_eos (GstPad *pad);
294 void gst_pad_handle_qos (GstPad *pad, glong qos_message);
296 xmlNodePtr gst_pad_save_thyself (GstPad *pad, xmlNodePtr parent);
297 void gst_pad_load_and_connect (xmlNodePtr parent, GstObject *element, GHashTable *elements);
301 GstPad * gst_ghost_pad_new (gchar *name,GstPad *pad);
305 /* templates and factories */
306 GtkType gst_padtemplate_get_type (void);
308 GstPadTemplate* gst_padtemplate_new (GstPadFactory *factory);
309 GstPadTemplate* gst_padtemplate_create (gchar *name_template,
310 GstPadDirection direction, GstPadPresence presence,
313 xmlNodePtr gst_padtemplate_save_thyself (GstPadTemplate *templ, xmlNodePtr parent);
314 GstPadTemplate* gst_padtemplate_load_thyself (xmlNodePtr parent);
318 #endif /* __cplusplus */
321 #endif /* __GST_PAD_H__ */