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,
99 gpointer element_private;
101 GstPadTemplate *padtemplate; /* the template for this pad */
104 struct _GstPadClass {
105 GstObjectClass parent_class;
112 GstPadDirection direction;
114 cothread_state *threadstate;
120 GstPadChainFunction chainfunc;
121 GstPadGetFunction getfunc;
122 GstPadGetRegionFunction getregionfunc;
123 GstPadQoSFunction qosfunc;
124 GstPadEOSFunction eosfunc;
126 GstPadPushFunction pushfunc;
127 GstPadPullFunction pullfunc;
128 GstPadPullRegionFunction pullregionfunc;
133 struct _GstRealPadClass {
134 GstPadClass parent_class;
136 /* signal callbacks */
137 void (*set_active) (GstPad *pad, gboolean active);
138 void (*caps_changed) (GstPad *pad, GstCaps *newcaps);
139 void (*eos) (GstPad *pad);
142 struct _GstGhostPad {
148 struct _GstGhostPadClass {
149 GstPadClass parent_class;
153 /***** helper macros *****/
155 #define GST_PAD_NAME(pad) (GST_OBJECT_NAME(pad))
156 #define GST_PAD_PARENT(pad) (GST_OBJECT_PARENT(pad))
157 #define GST_PAD_ELEMENT_PRIVATE(pad) (((GstPad *)(pad))->element_private)
158 #define GST_PAD_PADTEMPLATE(pad) (((GstPad *)(pad))->padtemplate)
161 #define GST_RPAD_DIRECTION(pad) (((GstRealPad *)(pad))->direction)
162 #define GST_RPAD_CAPS(pad) (((GstRealPad *)(pad))->caps)
163 #define GST_RPAD_PEER(pad) (((GstRealPad *)(pad))->peer)
164 #define GST_RPAD_BUFPEN(pad) (((GstRealPad *)(pad))->bufpen)
165 #define GST_RPAD_CHAINFUNC(pad) (((GstRealPad *)(pad))->chainfunc)
166 #define GST_RPAD_GETFUNC(pad) (((GstRealPad *)(pad))->getfunc)
167 #define GST_RPAD_GETREGIONFUNC(pad) (((GstRealPad *)(pad))->getregionfunc)
168 #define GST_RPAD_PUSHFUNC(pad) (((GstRealPad *)(pad))->pushfunc)
169 #define GST_RPAD_PULLFUNC(pad) (((GstRealPad *)(pad))->pullfunc)
170 #define GST_RPAD_PULLREGIONFUNC(pad) (((GstRealPad *)(pad))->pullregionfunc)
171 #define GST_RPAD_QOSFUNC(pad) (((GstRealPad *)(pad))->qosfunc)
172 #define GST_RPAD_EOSFUNC(pad) (((GstRealPad *)(pad))->eosfunc)
175 #define GST_GPAD_REALPAD(pad) (((GstGhostPad *)(pad))->realpad)
178 #define GST_PAD_REALIZE(pad) (GST_IS_REAL_PAD(pad) ? ((GstRealPad *)(pad)) : GST_GPAD_REALPAD(pad))
179 #define GST_PAD_DIRECTION(pad) GST_RPAD_DIRECTION(GST_PAD_REALIZE(pad))
180 #define GST_PAD_CAPS(pad) GST_RPAD_CAPS(GST_PAD_REALIZE(pad))
181 #define GST_PAD_PEER(pad) GST_RPAD_PEER(GST_PAD_REALIZE(pad))
183 /* Some check functions (unused?) */
184 #define GST_PAD_CONNECTED(pad) (GST_IS_REAL_PAD(pad) && GST_REAL_PAD(pad)->peer != NULL)
185 #define GST_PAD_CAN_PULL(pad) (GST_IS_REAL_PAD(pad) && GST_REAL_PAD(pad)->pullfunc != NULL)
188 /***** PadTemplate *****/
189 #define GST_TYPE_PADTEMPLATE (gst_padtemplate_get_type ())
190 #define GST_PADTEMPLATE(obj) (GTK_CHECK_CAST ((obj), GST_TYPE_PADTEMPLATE,GstPad))
191 #define GST_PADTEMPLATE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GST_TYPE_PADTEMPLATE,GstPadClass))
192 #define GST_IS_PADTEMPLATE(obj) (GTK_CHECK_TYPE ((obj), GST_TYPE_PADTEMPLATE))
193 #define GST_IS_PADTEMPLATE_CLASS(obj) (GTK_CHECK_CLASS_TYPE ((klass), GST_TYPE_PADTEMPLATE))
201 struct _GstPadTemplate {
204 gchar *name_template;
205 GstPadDirection direction;
206 GstPadPresence presence;
210 struct _GstPadTemplateClass {
211 GstObjectClass parent_class;
213 /* signal callbacks */
214 void (*pad_created) (GstPadTemplate *templ, GstPad *pad);
219 typedef gpointer GstPadFactoryEntry;
220 typedef GstPadFactoryEntry GstPadFactory[];
222 #define GST_PAD_FACTORY_ALWAYS GINT_TO_POINTER(GST_PAD_ALWAYS)
223 #define GST_PAD_FACTORY_SOMETIMES GINT_TO_POINTER(GST_PAD_SOMETIMES)
224 #define GST_PAD_FACTORY_REQUEST GINT_TO_POINTER(GST_PAD_REQUEST)
226 #define GST_PAD_FACTORY_SRC GINT_TO_POINTER(GST_PAD_SRC)
227 #define GST_PAD_FACTORY_SINK GINT_TO_POINTER(GST_PAD_SINK)
229 #define GST_PAD_FACTORY_CAPS(a...) GINT_TO_POINTER(1),##a,NULL
232 GtkType gst_pad_get_type (void);
233 GtkType gst_real_pad_get_type (void);
234 GtkType gst_ghost_pad_get_type (void);
236 GstPad* gst_pad_new (gchar *name, GstPadDirection direction);
237 #define gst_pad_destroy(pad) gst_object_destroy (GST_OBJECT (pad))
238 GstPad* gst_pad_new_from_template (GstPadTemplate *templ, gchar *name);
240 GstPadDirection gst_pad_get_direction (GstPad *pad);
242 void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
243 void gst_pad_set_get_function (GstPad *pad, GstPadGetFunction get);
244 void gst_pad_set_getregion_function (GstPad *pad, GstPadGetRegionFunction getregion);
245 void gst_pad_set_qos_function (GstPad *pad, GstPadQoSFunction qos);
246 void gst_pad_set_eos_function (GstPad *pad, GstPadEOSFunction eos);
248 void gst_pad_set_caps_list (GstPad *pad, GList *caps);
249 GList* gst_pad_get_caps_list (GstPad *pad);
250 GstCaps* gst_pad_get_caps_by_name (GstPad *pad, gchar *name);
251 gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad);
253 void gst_pad_set_element_private (GstPad *pad, gpointer priv);
254 gpointer gst_pad_get_element_private (GstPad *pad);
256 void gst_pad_set_name (GstPad *pad, const gchar *name);
257 const gchar* gst_pad_get_name (GstPad *pad);
259 void gst_pad_set_parent (GstPad *pad, GstObject *parent);
260 GstObject* gst_pad_get_parent (GstPad *pad);
262 void gst_pad_add_ghost_pad (GstPad *pad, GstPad *ghostpad);
263 void gst_pad_remove_ghost_pad (GstPad *pad, GstPad *ghostpad);
264 GList* gst_pad_get_ghost_pad_list (GstPad *pad);
266 GstPad* gst_pad_get_peer (GstPad *pad);
268 void gst_pad_connect (GstPad *srcpad, GstPad *sinkpad);
269 void gst_pad_disconnect (GstPad *srcpad, GstPad *sinkpad);
272 void gst_pad_push (GstPad *pad, GstBuffer *buffer);
274 #define gst_pad_push(pad,buf) G_STMT_START{ \
275 if ((pad)->peer->pushfunc) ((pad)->peer->pushfunc)((pad)->peer,(buf)); \
279 GstBuffer* gst_pad_pull (GstPad *pad);
280 GstBuffer* gst_pad_pull_region (GstPad *pad, gulong offset, gulong size);
282 #define gst_pad_pull(pad) \
283 (((pad)->peer->pullfunc) ? ((pad)->peer->pullfunc)((pad)->peer) : NULL)
284 #define gst_pad_pullregion(pad,offset,size) \
285 (((pad)->peer->pullregionfunc) ? ((pad)->peer->pullregionfunc)((pad)->peer,(offset),(size)) : NULL)
288 GstPad * gst_pad_select (GstPad *nextpad, ...);
290 #define gst_pad_eos(pad) (GST_RPAD_EOSFUNC(GST_RPAD_PEER(pad))(GST_PAD(GST_RPAD_PEER(pad))))
291 gboolean gst_pad_set_eos (GstPad *pad);
293 void gst_pad_handle_qos (GstPad *pad, glong qos_message);
295 void gst_pad_load_and_connect (xmlNodePtr self, GstObject *parent);
299 GstPad * gst_ghost_pad_new (gchar *name,GstPad *pad);
303 /* templates and factories */
304 GtkType gst_padtemplate_get_type (void);
306 GstPadTemplate* gst_padtemplate_new (GstPadFactory *factory);
307 GstPadTemplate* gst_padtemplate_create (gchar *name_template,
308 GstPadDirection direction, GstPadPresence presence,
311 xmlNodePtr gst_padtemplate_save_thyself (GstPadTemplate *templ, xmlNodePtr parent);
312 GstPadTemplate* gst_padtemplate_load_thyself (xmlNodePtr parent);
316 #endif /* __cplusplus */
319 #endif /* __GST_PAD_H__ */