baseparse: support reverse playback
[platform/upstream/gstreamer.git] / gst / gstbus.h
index b0fdcf5..732591f 100644 (file)
 #define __GST_BUS_H__
 
 typedef struct _GstBus GstBus;
+typedef struct _GstBusPrivate GstBusPrivate;
 typedef struct _GstBusClass GstBusClass;
 
 #include <gst/gstmessage.h>
 #include <gst/gstclock.h>
+#include <gst/gstatomicqueue.h>
 
 G_BEGIN_DECLS
 
@@ -64,7 +66,7 @@ typedef enum
 {
   GST_BUS_DROP = 0,
   GST_BUS_PASS = 1,
-  GST_BUS_ASYNC = 2,
+  GST_BUS_ASYNC = 2
 } GstBusSyncReply;
 
 /**
@@ -77,9 +79,12 @@ typedef enum
  * into the bus. This function is mostly used internally. Only one sync handler
  * can be attached to a given bus.
  *
+ * If the handler returns GST_BUS_DROP, it should unref the message, else the
+ * message should not be unreffed by the sync handler.
+ *
  * Returns: #GstBusSyncReply stating what to do with the message
  */
-typedef GstBusSyncReply (*GstBusSyncHandler)   (GstBus * bus, GstMessage * message, gpointer data);
+typedef GstBusSyncReply (*GstBusSyncHandler)    (GstBus * bus, GstMessage * message, gpointer data);
 
 /**
  * GstBusFunc:
@@ -87,33 +92,42 @@ typedef GstBusSyncReply (*GstBusSyncHandler)        (GstBus * bus, GstMessage * messag
  * @message: the #GstMessage
  * @data: user data that has been given, when registering the handler
  *
- * Specifies the type of function passed to #gst_bus_add_watch() or 
- * #gst_bus_add_watch_full(), which is called from the mainloop when a message
+ * Specifies the type of function passed to gst_bus_add_watch() or
+ * gst_bus_add_watch_full(), which is called from the mainloop when a message
  * is available on the bus.
  *
  * The message passed to the function will be unreffed after execution of this
- * function so it should not be freed in the function. 
+ * function so it should not be freed in the function.
+ *
+ * Note that this function is used as a GSourceFunc which means that returning
+ * FALSE will remove the GSource from the mainloop.
  *
- * Returns: %FALSE if the event source should be removed. 
+ * Returns: %FALSE if the event source should be removed.
  */
-typedef gboolean       (*GstBusFunc)           (GstBus * bus, GstMessage * message, gpointer data);
+typedef gboolean        (*GstBusFunc)           (GstBus * bus, GstMessage * message, gpointer data);
 
+/**
+ * GstBus:
+ *
+ * The opaque #GstBus data structure.
+ */
 struct _GstBus
 {
-  GstObject        object;
+  GstObject         object;
 
-  /*< private > */
-  GQueue           *queue;
+  /*< private >*/
+  GstAtomicQueue   *queue;
   GMutex           *queue_lock;
 
   GstBusSyncHandler sync_handler;
-  gpointer         sync_handler_data;
+  gpointer          sync_handler_data;
 
   guint             signal_watch_id;
   guint             num_signal_watchers;
 
-  /*< private > */
-  gpointer _gst_reserved[GST_PADDING];
+  /*< private >*/
+  GstBusPrivate    *priv;
+  gpointer _gst_reserved[GST_PADDING - 1];
 };
 
 struct _GstBusClass
@@ -121,51 +135,58 @@ struct _GstBusClass
   GstObjectClass parent_class;
 
   /* signals */
-  void (*message)      (GstBus *bus, GstMessage *message);
+  void (*message)       (GstBus *bus, GstMessage *message);
   void (*sync_message)  (GstBus *bus, GstMessage *message);
 
-  /*< private > */
+  /*< private >*/
   gpointer _gst_reserved[GST_PADDING];
 };
 
-GType                  gst_bus_get_type                (void);
+GType                   gst_bus_get_type                (void);
 
-GstBus*                        gst_bus_new                     (void);
+GstBus*                 gst_bus_new                     (void);
 
-gboolean               gst_bus_post                    (GstBus * bus, GstMessage * message);
+gboolean                gst_bus_post                    (GstBus * bus, GstMessage * message);
 
-gboolean               gst_bus_have_pending            (GstBus * bus);
-GstMessage *           gst_bus_peek                    (GstBus * bus);
-GstMessage *           gst_bus_pop                     (GstBus * bus);
-void                   gst_bus_set_flushing            (GstBus * bus, gboolean flushing);
+gboolean                gst_bus_have_pending            (GstBus * bus);
+GstMessage *            gst_bus_peek                    (GstBus * bus);
+GstMessage *            gst_bus_pop                     (GstBus * bus);
+GstMessage *            gst_bus_pop_filtered            (GstBus * bus, GstMessageType types);
+GstMessage *            gst_bus_timed_pop               (GstBus * bus, GstClockTime timeout);
+GstMessage *            gst_bus_timed_pop_filtered      (GstBus * bus, GstClockTime timeout, GstMessageType types);
+void                    gst_bus_set_flushing            (GstBus * bus, gboolean flushing);
 
 /* synchronous dispatching */
-void                   gst_bus_set_sync_handler        (GstBus * bus, GstBusSyncHandler func,
-                                                        gpointer data);
+void                    gst_bus_set_sync_handler        (GstBus * bus, GstBusSyncHandler func,
+                                                         gpointer data);
 /* GSource based dispatching */
-GSource *              gst_bus_create_watch            (GstBus * bus);
-guint                  gst_bus_add_watch_full          (GstBus * bus,
-                                                        gint priority,
-                                                        GstBusFunc func, 
-                                                        gpointer user_data, 
-                                                        GDestroyNotify notify);
-guint                  gst_bus_add_watch               (GstBus * bus,
-                                                        GstBusFunc func, 
-                                                        gpointer user_data);
+GSource *               gst_bus_create_watch            (GstBus * bus);
+guint                   gst_bus_add_watch_full          (GstBus * bus,
+                                                         gint priority,
+                                                         GstBusFunc func,
+                                                         gpointer user_data,
+                                                         GDestroyNotify notify);
+guint                   gst_bus_add_watch               (GstBus * bus,
+                                                         GstBusFunc func,
+                                                         gpointer user_data);
 
 /* polling the bus */
-GstMessage*            gst_bus_poll                    (GstBus *bus, GstMessageType events,
+GstMessage*             gst_bus_poll                    (GstBus *bus, GstMessageType events,
                                                          GstClockTimeDiff timeout);
 
 /* signal based dispatching helper functions. */
-gboolean               gst_bus_async_signal_func       (GstBus *bus, GstMessage *message,
-                                                        gpointer data);
-GstBusSyncReply                gst_bus_sync_signal_handler     (GstBus *bus, GstMessage *message,
-                                                        gpointer data);
+gboolean                gst_bus_async_signal_func       (GstBus *bus, GstMessage *message,
+                                                         gpointer data);
+GstBusSyncReply         gst_bus_sync_signal_handler     (GstBus *bus, GstMessage *message,
+                                                         gpointer data);
 
 /* convenience api to add/remove a gsource that emits the async signals */
-void                   gst_bus_add_signal_watch        (GstBus * bus);
-void                   gst_bus_remove_signal_watch     (GstBus * bus);
+void                    gst_bus_add_signal_watch        (GstBus * bus);
+void                    gst_bus_add_signal_watch_full   (GstBus * bus, gint priority);
+void                    gst_bus_remove_signal_watch     (GstBus * bus);
+
+void                    gst_bus_enable_sync_message_emission (GstBus * bus);
+void                    gst_bus_disable_sync_message_emission (GstBus * bus);
 
 G_END_DECLS