Blame gst/gstbus.h

Packit Service 963350
/* GStreamer
Packit Service 963350
 * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
Packit Service 963350
 *
Packit Service 963350
 * gstbus.h: Header for GstBus subsystem
Packit Service 963350
 *
Packit Service 963350
 * This library is free software; you can redistribute it and/or
Packit Service 963350
 * modify it under the terms of the GNU Library General Public
Packit Service 963350
 * License as published by the Free Software Foundation; either
Packit Service 963350
 * version 2 of the License, or (at your option) any later version.
Packit Service 963350
 *
Packit Service 963350
 * This library is distributed in the hope that it will be useful,
Packit Service 963350
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 963350
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 963350
 * Library General Public License for more details.
Packit Service 963350
 *
Packit Service 963350
 * You should have received a copy of the GNU Library General Public
Packit Service 963350
 * License along with this library; if not, write to the
Packit Service 963350
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit Service 963350
 * Boston, MA 02110-1301, USA.
Packit Service 963350
 */
Packit Service 963350
Packit Service 963350
#ifndef __GST_BUS_H__
Packit Service 963350
#define __GST_BUS_H__
Packit Service 963350
Packit Service 963350
typedef struct _GstBus GstBus;
Packit Service 963350
typedef struct _GstBusPrivate GstBusPrivate;
Packit Service 963350
typedef struct _GstBusClass GstBusClass;
Packit Service 963350
Packit Service 963350
#include <gst/gstmessage.h>
Packit Service 963350
#include <gst/gstclock.h>
Packit Service 963350
Packit Service 963350
G_BEGIN_DECLS
Packit Service 963350
Packit Service 963350
/* --- standard type macros --- */
Packit Service 963350
#define GST_TYPE_BUS              (gst_bus_get_type ())
Packit Service 963350
#define GST_BUS(bus)              (G_TYPE_CHECK_INSTANCE_CAST ((bus), GST_TYPE_BUS, GstBus))
Packit Service 963350
#define GST_IS_BUS(bus)           (G_TYPE_CHECK_INSTANCE_TYPE ((bus), GST_TYPE_BUS))
Packit Service 963350
#define GST_BUS_CLASS(bclass)     (G_TYPE_CHECK_CLASS_CAST ((bclass), GST_TYPE_BUS, GstBusClass))
Packit Service 963350
#define GST_IS_BUS_CLASS(bclass)  (G_TYPE_CHECK_CLASS_TYPE ((bclass), GST_TYPE_BUS))
Packit Service 963350
#define GST_BUS_GET_CLASS(bus)    (G_TYPE_INSTANCE_GET_CLASS ((bus), GST_TYPE_BUS, GstBusClass))
Packit Service 963350
#define GST_BUS_CAST(bus)         ((GstBus*)(bus))
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstBusFlags:
Packit Service 963350
 * @GST_BUS_FLUSHING: The bus is currently dropping all messages
Packit Service 963350
 * @GST_BUS_FLAG_LAST: offset to define more flags
Packit Service 963350
 *
Packit Service 963350
 * The standard flags that a bus may have.
Packit Service 963350
 */
Packit Service 963350
typedef enum {
Packit Service 963350
  GST_BUS_FLUSHING      = (GST_OBJECT_FLAG_LAST << 0),
Packit Service 963350
  /* padding */
Packit Service 963350
  GST_BUS_FLAG_LAST     = (GST_OBJECT_FLAG_LAST << 1)
Packit Service 963350
} GstBusFlags;
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstBusSyncReply:
Packit Service 963350
 * @GST_BUS_DROP: drop the message
Packit Service 963350
 * @GST_BUS_PASS: pass the message to the async queue
Packit Service 963350
 * @GST_BUS_ASYNC: pass message to async queue, continue if message is handled
Packit Service 963350
 *
Packit Service 963350
 * The result values for a GstBusSyncHandler.
Packit Service 963350
 */
Packit Service 963350
typedef enum
Packit Service 963350
{
Packit Service 963350
  GST_BUS_DROP = 0,
Packit Service 963350
  GST_BUS_PASS = 1,
Packit Service 963350
  GST_BUS_ASYNC = 2
Packit Service 963350
} GstBusSyncReply;
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstBusSyncHandler:
Packit Service 963350
 * @bus: the #GstBus that sent the message
Packit Service 963350
 * @message: the #GstMessage
Packit Service 963350
 * @user_data: user data that has been given, when registering the handler
Packit Service 963350
 *
Packit Service 963350
 * Handler will be invoked synchronously, when a new message has been injected
Packit Service 963350
 * into the bus. This function is mostly used internally. Only one sync handler
Packit Service 963350
 * can be attached to a given bus.
Packit Service 963350
 *
Packit Service 963350
 * If the handler returns GST_BUS_DROP, it should unref the message, else the
Packit Service 963350
 * message should not be unreffed by the sync handler.
Packit Service 963350
 *
Packit Service 963350
 * Returns: #GstBusSyncReply stating what to do with the message
Packit Service 963350
 */
Packit Service 963350
typedef GstBusSyncReply (*GstBusSyncHandler)    (GstBus * bus, GstMessage * message, gpointer user_data);
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstBusFunc:
Packit Service 963350
 * @bus: the #GstBus that sent the message
Packit Service 963350
 * @message: the #GstMessage
Packit Service 963350
 * @user_data: user data that has been given, when registering the handler
Packit Service 963350
 *
Packit Service 963350
 * Specifies the type of function passed to gst_bus_add_watch() or
Packit Service 963350
 * gst_bus_add_watch_full(), which is called from the mainloop when a message
Packit Service 963350
 * is available on the bus.
Packit Service 963350
 *
Packit Service 963350
 * The message passed to the function will be unreffed after execution of this
Packit Service 963350
 * function so it should not be freed in the function.
Packit Service 963350
 *
Packit Service 963350
 * Note that this function is used as a GSourceFunc which means that returning
Packit Service 963350
 * %FALSE will remove the GSource from the mainloop.
Packit Service 963350
 *
Packit Service 963350
 * Returns: %FALSE if the event source should be removed.
Packit Service 963350
 */
Packit Service 963350
typedef gboolean        (*GstBusFunc)           (GstBus * bus, GstMessage * message, gpointer user_data);
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * GstBus:
Packit Service 963350
 *
Packit Service 963350
 * The opaque #GstBus data structure.
Packit Service 963350
 */
Packit Service 963350
struct _GstBus
Packit Service 963350
{
Packit Service 963350
  GstObject         object;
Packit Service 963350
Packit Service 963350
  /*< private >*/
Packit Service 963350
  GstBusPrivate    *priv;
Packit Service 963350
Packit Service 963350
  gpointer _gst_reserved[GST_PADDING];
Packit Service 963350
};
Packit Service 963350
Packit Service 963350
struct _GstBusClass
Packit Service 963350
{
Packit Service 963350
  GstObjectClass parent_class;
Packit Service 963350
Packit Service 963350
  /* signals */
Packit Service 963350
  void (*message)       (GstBus *bus, GstMessage *message);
Packit Service 963350
  void (*sync_message)  (GstBus *bus, GstMessage *message);
Packit Service 963350
Packit Service 963350
  /*< private >*/
Packit Service 963350
  gpointer _gst_reserved[GST_PADDING];
Packit Service 963350
};
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GType                   gst_bus_get_type                (void);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstBus*                 gst_bus_new                     (void);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
gboolean                gst_bus_post                    (GstBus * bus, GstMessage * message);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
gboolean                gst_bus_have_pending            (GstBus * bus);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstMessage *            gst_bus_peek                    (GstBus * bus);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstMessage *            gst_bus_pop                     (GstBus * bus);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstMessage *            gst_bus_pop_filtered            (GstBus * bus, GstMessageType types);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstMessage *            gst_bus_timed_pop               (GstBus * bus, GstClockTime timeout);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstMessage *            gst_bus_timed_pop_filtered      (GstBus * bus, GstClockTime timeout, GstMessageType types);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void                    gst_bus_set_flushing            (GstBus * bus, gboolean flushing);
Packit Service 963350
Packit Service 963350
/* synchronous dispatching */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void                    gst_bus_set_sync_handler        (GstBus * bus, GstBusSyncHandler func,
Packit Service 963350
                                                         gpointer user_data, GDestroyNotify notify);
Packit Service 963350
Packit Service 963350
/* asynchronous message notifications */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void                    gst_bus_get_pollfd              (GstBus * bus, GPollFD *fd);
Packit Service 963350
Packit Service 963350
/* GSource based dispatching */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GSource *               gst_bus_create_watch            (GstBus * bus);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
guint                   gst_bus_add_watch_full          (GstBus * bus,
Packit Service 963350
                                                         gint priority,
Packit Service 963350
                                                         GstBusFunc func,
Packit Service 963350
                                                         gpointer user_data,
Packit Service 963350
                                                         GDestroyNotify notify);
Packit Service 963350
GST_API
Packit Service 963350
guint                   gst_bus_add_watch               (GstBus * bus,
Packit Service 963350
                                                         GstBusFunc func,
Packit Service 963350
                                                         gpointer user_data);
Packit Service 963350
GST_API
Packit Service 963350
gboolean                gst_bus_remove_watch            (GstBus * bus);
Packit Service 963350
Packit Service 963350
/* polling the bus */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
GstMessage*             gst_bus_poll                    (GstBus *bus, GstMessageType events,
Packit Service 963350
                                                         GstClockTime timeout);
Packit Service 963350
Packit Service 963350
/* signal based dispatching helper functions. */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
gboolean                gst_bus_async_signal_func       (GstBus *bus, GstMessage *message,
Packit Service 963350
                                                         gpointer data);
Packit Service 963350
GST_API
Packit Service 963350
GstBusSyncReply         gst_bus_sync_signal_handler     (GstBus *bus, GstMessage *message,
Packit Service 963350
                                                         gpointer data);
Packit Service 963350
Packit Service 963350
/* convenience api to add/remove a gsource that emits the async signals */
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void                    gst_bus_add_signal_watch        (GstBus * bus);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void                    gst_bus_add_signal_watch_full   (GstBus * bus, gint priority);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void                    gst_bus_remove_signal_watch     (GstBus * bus);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void                    gst_bus_enable_sync_message_emission (GstBus * bus);
Packit Service 963350
Packit Service 963350
GST_API
Packit Service 963350
void                    gst_bus_disable_sync_message_emission (GstBus * bus);
Packit Service 963350
Packit Service 963350
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
Packit Service 963350
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstBus, gst_object_unref)
Packit Service 963350
#endif
Packit Service 963350
Packit Service 963350
G_END_DECLS
Packit Service 963350
Packit Service 963350
#endif /* __GST_BUS_H__ */