|
1 /* GStreamer |
|
2 * Copyright (C) 2004 Wim Taymans <wim@fluendo.com> |
|
3 * |
|
4 * gstbus.h: Header for GstBus subsystem |
|
5 * |
|
6 * This library is free software; you can redistribute it and/or |
|
7 * modify it under the terms of the GNU Library General Public |
|
8 * License as published by the Free Software Foundation; either |
|
9 * version 2 of the License, or (at your option) any later version. |
|
10 * |
|
11 * This library is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 * Library General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU Library General Public |
|
17 * License along with this library; if not, write to the |
|
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
19 * Boston, MA 02111-1307, USA. |
|
20 */ |
|
21 |
|
22 #ifndef __GST_BUS_H__ |
|
23 #define __GST_BUS_H__ |
|
24 |
|
25 typedef struct _GstBus GstBus; |
|
26 typedef struct _GstBusPrivate GstBusPrivate; |
|
27 typedef struct _GstBusClass GstBusClass; |
|
28 |
|
29 #include <gst/gstmessage.h> |
|
30 #include <gst/gstclock.h> |
|
31 |
|
32 G_BEGIN_DECLS |
|
33 |
|
34 /* --- standard type macros --- */ |
|
35 #define GST_TYPE_BUS (gst_bus_get_type ()) |
|
36 #define GST_BUS(bus) (G_TYPE_CHECK_INSTANCE_CAST ((bus), GST_TYPE_BUS, GstBus)) |
|
37 #define GST_IS_BUS(bus) (G_TYPE_CHECK_INSTANCE_TYPE ((bus), GST_TYPE_BUS)) |
|
38 #define GST_BUS_CLASS(bclass) (G_TYPE_CHECK_CLASS_CAST ((bclass), GST_TYPE_BUS, GstBusClass)) |
|
39 #define GST_IS_BUS_CLASS(bclass) (G_TYPE_CHECK_CLASS_TYPE ((bclass), GST_TYPE_BUS)) |
|
40 #define GST_BUS_GET_CLASS(bus) (G_TYPE_INSTANCE_GET_CLASS ((bus), GST_TYPE_BUS, GstBusClass)) |
|
41 #define GST_BUS_CAST(bus) ((GstBus*)(bus)) |
|
42 |
|
43 /** |
|
44 * GstBusFlags: |
|
45 * @GST_BUS_FLUSHING: The bus is currently dropping all messages |
|
46 * @GST_BUS_FLAG_LAST: offset to define more flags |
|
47 * |
|
48 * The standard flags that a bus may have. |
|
49 */ |
|
50 typedef enum { |
|
51 GST_BUS_FLUSHING = (GST_OBJECT_FLAG_LAST << 0), |
|
52 /* padding */ |
|
53 GST_BUS_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 1) |
|
54 } GstBusFlags; |
|
55 |
|
56 /** |
|
57 * GstBusSyncReply: |
|
58 * @GST_BUS_DROP: drop the message |
|
59 * @GST_BUS_PASS: pass the message to the async queue |
|
60 * @GST_BUS_ASYNC: pass message to async queue, continue if message is handled |
|
61 * |
|
62 * The result values for a GstBusSyncHandler. |
|
63 */ |
|
64 typedef enum |
|
65 { |
|
66 GST_BUS_DROP = 0, |
|
67 GST_BUS_PASS = 1, |
|
68 GST_BUS_ASYNC = 2 |
|
69 } GstBusSyncReply; |
|
70 |
|
71 /** |
|
72 * GstBusSyncHandler: |
|
73 * @bus: the #GstBus that sent the message |
|
74 * @message: the #GstMessage |
|
75 * @data: user data that has been given, when registering the handler |
|
76 * |
|
77 * Handler will be invoked synchronously, when a new message has been injected |
|
78 * into the bus. This function is mostly used internally. Only one sync handler |
|
79 * can be attached to a given bus. |
|
80 * |
|
81 * If the handler returns GST_BUS_DROP, it should unref the message, else the |
|
82 * message should not be unreffed by the sync handler. |
|
83 * |
|
84 * Returns: #GstBusSyncReply stating what to do with the message |
|
85 */ |
|
86 typedef GstBusSyncReply (*GstBusSyncHandler) (GstBus * bus, GstMessage * message, gpointer data); |
|
87 |
|
88 /** |
|
89 * GstBusFunc: |
|
90 * @bus: the #GstBus that sent the message |
|
91 * @message: the #GstMessage |
|
92 * @data: user data that has been given, when registering the handler |
|
93 * |
|
94 * Specifies the type of function passed to gst_bus_add_watch() or |
|
95 * gst_bus_add_watch_full(), which is called from the mainloop when a message |
|
96 * is available on the bus. |
|
97 * |
|
98 * The message passed to the function will be unreffed after execution of this |
|
99 * function so it should not be freed in the function. |
|
100 * |
|
101 * Note that this function is used as a GSourceFunc which means that returning |
|
102 * FALSE will remove the GSource from the mainloop. |
|
103 * |
|
104 * Returns: %FALSE if the event source should be removed. |
|
105 */ |
|
106 typedef gboolean (*GstBusFunc) (GstBus * bus, GstMessage * message, gpointer data); |
|
107 |
|
108 /** |
|
109 * GstBus: |
|
110 * |
|
111 * The opaque #GstBus data structure. |
|
112 */ |
|
113 struct _GstBus |
|
114 { |
|
115 GstObject object; |
|
116 |
|
117 /*< private > */ |
|
118 GQueue *queue; |
|
119 GMutex *queue_lock; |
|
120 |
|
121 GstBusSyncHandler sync_handler; |
|
122 gpointer sync_handler_data; |
|
123 |
|
124 guint signal_watch_id; |
|
125 guint num_signal_watchers; |
|
126 |
|
127 /*< private > */ |
|
128 GstBusPrivate *priv; |
|
129 gpointer _gst_reserved[GST_PADDING - 1]; |
|
130 }; |
|
131 |
|
132 struct _GstBusClass |
|
133 { |
|
134 GstObjectClass parent_class; |
|
135 |
|
136 /* signals */ |
|
137 void (*message) (GstBus *bus, GstMessage *message); |
|
138 void (*sync_message) (GstBus *bus, GstMessage *message); |
|
139 |
|
140 /*< private > */ |
|
141 gpointer _gst_reserved[GST_PADDING]; |
|
142 }; |
|
143 #ifdef __SYMBIAN32__ |
|
144 IMPORT_C |
|
145 #endif |
|
146 |
|
147 |
|
148 GType gst_bus_get_type (void); |
|
149 #ifdef __SYMBIAN32__ |
|
150 IMPORT_C |
|
151 #endif |
|
152 |
|
153 |
|
154 GstBus* gst_bus_new (void); |
|
155 #ifdef __SYMBIAN32__ |
|
156 IMPORT_C |
|
157 #endif |
|
158 |
|
159 |
|
160 gboolean gst_bus_post (GstBus * bus, GstMessage * message); |
|
161 #ifdef __SYMBIAN32__ |
|
162 IMPORT_C |
|
163 #endif |
|
164 |
|
165 |
|
166 gboolean gst_bus_have_pending (GstBus * bus); |
|
167 #ifdef __SYMBIAN32__ |
|
168 IMPORT_C |
|
169 #endif |
|
170 |
|
171 GstMessage * gst_bus_peek (GstBus * bus); |
|
172 #ifdef __SYMBIAN32__ |
|
173 IMPORT_C |
|
174 #endif |
|
175 |
|
176 GstMessage * gst_bus_pop (GstBus * bus); |
|
177 #ifdef __SYMBIAN32__ |
|
178 IMPORT_C |
|
179 #endif |
|
180 |
|
181 GstMessage * gst_bus_pop_filtered (GstBus * bus, GstMessageType types); |
|
182 #ifdef __SYMBIAN32__ |
|
183 IMPORT_C |
|
184 #endif |
|
185 |
|
186 GstMessage * gst_bus_timed_pop (GstBus * bus, GstClockTime timeout); |
|
187 #ifdef __SYMBIAN32__ |
|
188 IMPORT_C |
|
189 #endif |
|
190 |
|
191 GstMessage * gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout, GstMessageType types); |
|
192 #ifdef __SYMBIAN32__ |
|
193 IMPORT_C |
|
194 #endif |
|
195 |
|
196 void gst_bus_set_flushing (GstBus * bus, gboolean flushing); |
|
197 |
|
198 /* synchronous dispatching */ |
|
199 #ifdef __SYMBIAN32__ |
|
200 IMPORT_C |
|
201 #endif |
|
202 |
|
203 void gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func, |
|
204 gpointer data); |
|
205 /* GSource based dispatching */ |
|
206 #ifdef __SYMBIAN32__ |
|
207 IMPORT_C |
|
208 #endif |
|
209 |
|
210 GSource * gst_bus_create_watch (GstBus * bus); |
|
211 #ifdef __SYMBIAN32__ |
|
212 IMPORT_C |
|
213 #endif |
|
214 |
|
215 guint gst_bus_add_watch_full (GstBus * bus, |
|
216 gint priority, |
|
217 GstBusFunc func, |
|
218 gpointer user_data, |
|
219 GDestroyNotify notify); |
|
220 #ifdef __SYMBIAN32__ |
|
221 IMPORT_C |
|
222 #endif |
|
223 |
|
224 guint gst_bus_add_watch (GstBus * bus, |
|
225 GstBusFunc func, |
|
226 gpointer user_data); |
|
227 |
|
228 /* polling the bus */ |
|
229 #ifdef __SYMBIAN32__ |
|
230 IMPORT_C |
|
231 #endif |
|
232 |
|
233 GstMessage* gst_bus_poll (GstBus *bus, GstMessageType events, |
|
234 GstClockTimeDiff timeout); |
|
235 |
|
236 /* signal based dispatching helper functions. */ |
|
237 #ifdef __SYMBIAN32__ |
|
238 IMPORT_C |
|
239 #endif |
|
240 |
|
241 gboolean gst_bus_async_signal_func (GstBus *bus, GstMessage *message, |
|
242 gpointer data); |
|
243 #ifdef __SYMBIAN32__ |
|
244 IMPORT_C |
|
245 #endif |
|
246 |
|
247 GstBusSyncReply gst_bus_sync_signal_handler (GstBus *bus, GstMessage *message, |
|
248 gpointer data); |
|
249 |
|
250 /* convenience api to add/remove a gsource that emits the async signals */ |
|
251 #ifdef __SYMBIAN32__ |
|
252 IMPORT_C |
|
253 #endif |
|
254 |
|
255 void gst_bus_add_signal_watch (GstBus * bus); |
|
256 #ifdef __SYMBIAN32__ |
|
257 IMPORT_C |
|
258 #endif |
|
259 |
|
260 void gst_bus_add_signal_watch_full (GstBus * bus, gint priority); |
|
261 #ifdef __SYMBIAN32__ |
|
262 IMPORT_C |
|
263 #endif |
|
264 |
|
265 void gst_bus_remove_signal_watch (GstBus * bus); |
|
266 #ifdef __SYMBIAN32__ |
|
267 IMPORT_C |
|
268 #endif |
|
269 |
|
270 |
|
271 void gst_bus_enable_sync_message_emission (GstBus * bus); |
|
272 #ifdef __SYMBIAN32__ |
|
273 IMPORT_C |
|
274 #endif |
|
275 |
|
276 void gst_bus_disable_sync_message_emission (GstBus * bus); |
|
277 |
|
278 G_END_DECLS |
|
279 |
|
280 #endif /* __GST_BUS_H__ */ |