more docs and two more inlined
[platform/upstream/gstreamer.git] / gst / gstbus.h
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 _GstBusClass GstBusClass;
27
28 #include <gst/gstmessage.h>
29 #include <gst/gstclock.h>
30
31 G_BEGIN_DECLS
32
33 /* --- standard type macros --- */
34 #define GST_TYPE_BUS              (gst_bus_get_type ())
35 #define GST_BUS(bus)              (G_TYPE_CHECK_INSTANCE_CAST ((bus), GST_TYPE_BUS, GstBus))
36 #define GST_IS_BUS(bus)           (G_TYPE_CHECK_INSTANCE_TYPE ((bus), GST_TYPE_BUS))
37 #define GST_BUS_CLASS(bclass)     (G_TYPE_CHECK_CLASS_CAST ((bclass), GST_TYPE_BUS, GstBusClass))
38 #define GST_IS_BUS_CLASS(bclass)  (G_TYPE_CHECK_CLASS_TYPE ((bclass), GST_TYPE_BUS))
39 #define GST_BUS_GET_CLASS(bus)    (G_TYPE_INSTANCE_GET_CLASS ((bus), GST_TYPE_BUS, GstBusClass))
40 #define GST_BUS_CAST(bus)         ((GstBus*)(bus))
41
42 typedef enum {
43   GST_BUS_FLUSHING              = GST_OBJECT_FLAG_LAST,
44
45   GST_BUS_FLAG_LAST             = GST_OBJECT_FLAG_LAST + 1
46 } GstBusFlags;
47
48 typedef enum
49 {
50   GST_BUS_DROP = 0,             /* drop message */
51   GST_BUS_PASS = 1,             /* pass message to async queue */
52   GST_BUS_ASYNC = 2,            /* pass message to async queue, continue if message is handled */
53 } GstBusSyncReply;
54
55 /**
56  * GstBusSyncHandler:
57  * @bus: the #GstBus that sent the message
58  * @messages: the #GstMessage
59  * @data: user data that has been given, when registering the handler
60  *
61  * Handler will be invoked synchronously, when a new message has been injected
62  * into the bus.
63  *
64  * Returns: #GstBusSyncReply stating what to do with the message
65  */
66 typedef GstBusSyncReply (*GstBusSyncHandler)    (GstBus * bus, GstMessage * message, gpointer data);
67 /**
68  * GstBusHandler:
69  * @bus: the #GstBus that sent the message
70  * @messages: the #GstMessage
71  * @data: user data that has been given, when registering the handler
72  *
73  * Handler will be invoked asynchronously, after a new message has been injected
74  * into the bus. Return %TRUE if the message has been handled. It will then be
75  * taken from the bus and _unref()'ed.
76  *
77  * Returns: %TRUE if message should be taken from the bus
78  */
79 typedef gboolean        (*GstBusHandler)        (GstBus * bus, GstMessage * message, gpointer data);
80
81 struct _GstBus
82 {
83   GstObject         object;
84
85   /*< private > */
86   GQueue           *queue;
87   GMutex           *queue_lock;
88
89   GstBusSyncHandler sync_handler;
90   gpointer          sync_handler_data;
91
92   /*< private > */
93   gpointer _gst_reserved[GST_PADDING];
94 };
95
96 struct _GstBusClass
97 {
98   GstObjectClass parent_class;
99
100   /*< private > */
101   gpointer _gst_reserved[GST_PADDING];
102 };
103
104 GType                   gst_bus_get_type                (void);
105
106 GstBus*                 gst_bus_new                     (void);
107
108 gboolean                gst_bus_post                    (GstBus * bus, GstMessage * message);
109
110 gboolean                gst_bus_have_pending            (GstBus * bus);
111 GstMessage *            gst_bus_peek                    (GstBus * bus);
112 GstMessage *            gst_bus_pop                     (GstBus * bus);
113 void                    gst_bus_set_flushing            (GstBus * bus, gboolean flushing);
114
115 void                    gst_bus_set_sync_handler        (GstBus * bus, GstBusSyncHandler func,
116                                                          gpointer data);
117
118 GSource *               gst_bus_create_watch            (GstBus * bus);
119 guint                   gst_bus_add_watch_full          (GstBus * bus,
120                                                          gint priority,
121                                                          GstBusHandler handler, 
122                                                          gpointer user_data, 
123                                                          GDestroyNotify notify);
124 guint                   gst_bus_add_watch               (GstBus * bus,
125                                                          GstBusHandler handler, 
126                                                          gpointer user_data);
127 GstMessageType          gst_bus_poll                    (GstBus *bus, GstMessageType events,
128                                                          GstClockTimeDiff timeout);
129
130 G_END_DECLS
131
132 #endif /* __GST_BUS_H__ */