2004-12-08 18:05:14 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
|
|
|
|
*
|
|
|
|
* gstbus.h: Header for GstBus subsystem
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_BUS_H__
|
|
|
|
#define __GST_BUS_H__
|
|
|
|
|
|
|
|
#include <gst/gsttypes.h>
|
|
|
|
#include <gst/gstmessage.h>
|
gst/gstmessage.h (GstMessageType): Turned into flags. Added
Original commit message from CVS:
2005-02-21 Andy Wingo <wingo@pobox.com>
* gst/gstmessage.h (GstMessageType): Turned into flags. Added
GST_MESSAGE_ANY as an OR of all flags.
(GST_MESSAGE_PARSE_STATE_CHANGED): New terrible macro. Will be
made into a function soon.
(GstMessage): Add a state_changed structure to the union. The
union will die soon in favor of a single GstStructure tho.
(gst_message_new_state_changed): New API.
* gst/gstmessage.c (gst_message_new_state_changed): New API.
* tools/gst-launch.c (check_intr): Set the state of the pipeline
to PAUSED here; the poll will catch the state change.
(event_loop): New function, polls the pipeline bus for events. Can
block until eos/error/state change, or just handle the pending
events.
(main): Changed to use event_loop instead of running a main loop.
* gst/gstbus.h (gst_bus_poll): Added.
(gst_bus_peek): Return non-const; the message is refcounted
anyway.
* gst/gstbus.c (gst_bus_init): Replace the GAsyncQueue with a
GQueue+mutex to allow for _peek. (The wake-up functionality
provided by GAsyncQueue is already done by our socketpair.) All
queue users changed to lock, operate, and unlock.
(gst_bus_post): Check the retval of write(2) and handle errno.
(gst_bus_peek): Implemented.
(gst_bus_pop, gst_bus_peek, bus_callback): Because the socketpair
is used to wake up the GSource, read off the character in the
GSource handler and not in pop/peek. This is because a peek will
require a pop in the future, and you can't read off the char
twice. Deal with errno in the read.
(bus_callback): Interpret the handler return value as whether or
not to pop the message from the bus.
(poll_handler, poll_timeout, gst_bus_poll): New API. gst_bus_poll
is meant to replace the while(gst_bin_iterate()) idiom.
2005-02-21 11:54:55 +00:00
|
|
|
#include <gst/gstclock.h>
|
2004-12-08 18:05:14 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
2005-01-06 18:17:12 +00:00
|
|
|
|
2004-12-08 18:05:14 +00:00
|
|
|
/* --- standard type macros --- */
|
|
|
|
#define GST_TYPE_BUS (gst_bus_get_type ())
|
|
|
|
#define GST_BUS(bus) (G_TYPE_CHECK_INSTANCE_CAST ((bus), GST_TYPE_BUS, GstBus))
|
|
|
|
#define GST_IS_BUS(bus) (G_TYPE_CHECK_INSTANCE_TYPE ((bus), GST_TYPE_BUS))
|
|
|
|
#define GST_BUS_CLASS(bclass) (G_TYPE_CHECK_CLASS_CAST ((bclass), GST_TYPE_BUS, GstBusClass))
|
|
|
|
#define GST_IS_BUS_CLASS(bclass) (G_TYPE_CHECK_CLASS_TYPE ((bclass), GST_TYPE_BUS))
|
|
|
|
#define GST_BUS_GET_CLASS(bus) (G_TYPE_INSTANCE_GET_CLASS ((bus), GST_TYPE_BUS, GstBusClass))
|
More MT fixes. Header cleanups, design doc update.
Original commit message from CVS:
* docs/design/part-MT-refcounting.txt:
* gst/gstbin.c: (gst_bin_set_index), (gst_bin_set_clock),
(gst_bin_add_func), (gst_bin_add), (gst_bin_remove_func),
(gst_bin_remove), (gst_bin_iterate_elements),
(bin_element_is_sink), (gst_bin_get_state), (gst_bin_change_state),
(gst_bin_get_by_name), (gst_bin_get_by_name_recurse_up),
(gst_bin_get_by_interface), (gst_bin_get_all_by_interface):
* gst/gstbin.h:
* gst/gstbuffer.h:
* gst/gstbus.h:
* gst/gstcaps.h:
* gst/gstclock.h:
* gst/gstdata.h:
* gst/gstelement.h:
* gst/gstevent.h:
* gst/gstmessage.h:
* gst/gststructure.h:
More MT fixes. Header cleanups, design doc update.
2004-12-09 23:28:31 +00:00
|
|
|
#define GST_BUS_CAST(bus) ((GstBus*)(bus))
|
2005-01-06 18:17:12 +00:00
|
|
|
|
|
|
|
typedef enum
|
2004-12-08 18:05:14 +00:00
|
|
|
{
|
2004-12-13 14:49:11 +00:00
|
|
|
GST_BUS_DROP = 0, /* drop message */
|
|
|
|
GST_BUS_PASS = 1, /* pass message to async queue */
|
|
|
|
GST_BUS_ASYNC = 2, /* pass message to async queue, continue if message is handled */
|
2004-12-08 18:05:14 +00:00
|
|
|
} GstBusSyncReply;
|
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
typedef GstBusSyncReply (*GstBusSyncHandler) (GstBus * bus, GstMessage * message, gpointer data);
|
|
|
|
typedef gboolean (*GstBusHandler) (GstBus * bus, GstMessage * message, gpointer data);
|
2004-12-08 18:05:14 +00:00
|
|
|
|
2004-12-13 14:49:11 +00:00
|
|
|
struct _GstBus
|
|
|
|
{
|
2005-01-06 18:17:12 +00:00
|
|
|
GstObject object;
|
2004-12-08 18:05:14 +00:00
|
|
|
|
2004-12-13 14:49:11 +00:00
|
|
|
/*< private > */
|
gst/gstmessage.h (GstMessageType): Turned into flags. Added
Original commit message from CVS:
2005-02-21 Andy Wingo <wingo@pobox.com>
* gst/gstmessage.h (GstMessageType): Turned into flags. Added
GST_MESSAGE_ANY as an OR of all flags.
(GST_MESSAGE_PARSE_STATE_CHANGED): New terrible macro. Will be
made into a function soon.
(GstMessage): Add a state_changed structure to the union. The
union will die soon in favor of a single GstStructure tho.
(gst_message_new_state_changed): New API.
* gst/gstmessage.c (gst_message_new_state_changed): New API.
* tools/gst-launch.c (check_intr): Set the state of the pipeline
to PAUSED here; the poll will catch the state change.
(event_loop): New function, polls the pipeline bus for events. Can
block until eos/error/state change, or just handle the pending
events.
(main): Changed to use event_loop instead of running a main loop.
* gst/gstbus.h (gst_bus_poll): Added.
(gst_bus_peek): Return non-const; the message is refcounted
anyway.
* gst/gstbus.c (gst_bus_init): Replace the GAsyncQueue with a
GQueue+mutex to allow for _peek. (The wake-up functionality
provided by GAsyncQueue is already done by our socketpair.) All
queue users changed to lock, operate, and unlock.
(gst_bus_post): Check the retval of write(2) and handle errno.
(gst_bus_peek): Implemented.
(gst_bus_pop, gst_bus_peek, bus_callback): Because the socketpair
is used to wake up the GSource, read off the character in the
GSource handler and not in pop/peek. This is because a peek will
require a pop in the future, and you can't read off the char
twice. Deal with errno in the read.
(bus_callback): Interpret the handler return value as whether or
not to pop the message from the bus.
(poll_handler, poll_timeout, gst_bus_poll): New API. gst_bus_poll
is meant to replace the while(gst_bin_iterate()) idiom.
2005-02-21 11:54:55 +00:00
|
|
|
GQueue *queue;
|
|
|
|
GMutex *queue_lock;
|
2004-12-08 18:05:14 +00:00
|
|
|
|
2004-12-13 14:49:11 +00:00
|
|
|
GstBusSyncHandler sync_handler;
|
2005-01-06 18:17:12 +00:00
|
|
|
gpointer sync_handler_data;
|
2004-12-08 18:05:14 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
gint control_socket[2];
|
|
|
|
GIOChannel *io_channel;
|
2004-12-08 18:05:14 +00:00
|
|
|
|
2004-12-13 14:49:11 +00:00
|
|
|
/*< private > */
|
2004-12-08 18:05:14 +00:00
|
|
|
gpointer _gst_reserved[GST_PADDING];
|
|
|
|
};
|
|
|
|
|
2004-12-13 14:49:11 +00:00
|
|
|
struct _GstBusClass
|
|
|
|
{
|
|
|
|
GstObjectClass parent_class;
|
2004-12-08 18:05:14 +00:00
|
|
|
|
2004-12-13 14:49:11 +00:00
|
|
|
/*< private > */
|
2004-12-08 18:05:14 +00:00
|
|
|
gpointer _gst_reserved[GST_PADDING];
|
|
|
|
};
|
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
GType gst_bus_get_type (void);
|
2004-12-08 18:05:14 +00:00
|
|
|
|
2005-01-18 10:52:08 +00:00
|
|
|
GstBus* gst_bus_new (void);
|
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
gboolean gst_bus_post (GstBus * bus, GstMessage * message);
|
2004-12-08 18:05:14 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
gboolean gst_bus_have_pending (GstBus * bus);
|
gst/gstmessage.h (GstMessageType): Turned into flags. Added
Original commit message from CVS:
2005-02-21 Andy Wingo <wingo@pobox.com>
* gst/gstmessage.h (GstMessageType): Turned into flags. Added
GST_MESSAGE_ANY as an OR of all flags.
(GST_MESSAGE_PARSE_STATE_CHANGED): New terrible macro. Will be
made into a function soon.
(GstMessage): Add a state_changed structure to the union. The
union will die soon in favor of a single GstStructure tho.
(gst_message_new_state_changed): New API.
* gst/gstmessage.c (gst_message_new_state_changed): New API.
* tools/gst-launch.c (check_intr): Set the state of the pipeline
to PAUSED here; the poll will catch the state change.
(event_loop): New function, polls the pipeline bus for events. Can
block until eos/error/state change, or just handle the pending
events.
(main): Changed to use event_loop instead of running a main loop.
* gst/gstbus.h (gst_bus_poll): Added.
(gst_bus_peek): Return non-const; the message is refcounted
anyway.
* gst/gstbus.c (gst_bus_init): Replace the GAsyncQueue with a
GQueue+mutex to allow for _peek. (The wake-up functionality
provided by GAsyncQueue is already done by our socketpair.) All
queue users changed to lock, operate, and unlock.
(gst_bus_post): Check the retval of write(2) and handle errno.
(gst_bus_peek): Implemented.
(gst_bus_pop, gst_bus_peek, bus_callback): Because the socketpair
is used to wake up the GSource, read off the character in the
GSource handler and not in pop/peek. This is because a peek will
require a pop in the future, and you can't read off the char
twice. Deal with errno in the read.
(bus_callback): Interpret the handler return value as whether or
not to pop the message from the bus.
(poll_handler, poll_timeout, gst_bus_poll): New API. gst_bus_poll
is meant to replace the while(gst_bin_iterate()) idiom.
2005-02-21 11:54:55 +00:00
|
|
|
GstMessage * gst_bus_peek (GstBus * bus);
|
2005-01-06 18:17:12 +00:00
|
|
|
GstMessage * gst_bus_pop (GstBus * bus);
|
2004-12-08 18:05:14 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
void gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func,
|
|
|
|
gpointer data);
|
2004-12-08 18:05:14 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
GSource * gst_bus_create_watch (GstBus * bus);
|
|
|
|
guint gst_bus_add_watch_full (GstBus * bus,
|
|
|
|
gint priority,
|
|
|
|
GstBusHandler handler,
|
|
|
|
gpointer user_data,
|
|
|
|
GDestroyNotify notify);
|
|
|
|
guint gst_bus_add_watch (GstBus * bus,
|
|
|
|
GstBusHandler handler,
|
|
|
|
gpointer user_data);
|
gst/gstmessage.h (GstMessageType): Turned into flags. Added
Original commit message from CVS:
2005-02-21 Andy Wingo <wingo@pobox.com>
* gst/gstmessage.h (GstMessageType): Turned into flags. Added
GST_MESSAGE_ANY as an OR of all flags.
(GST_MESSAGE_PARSE_STATE_CHANGED): New terrible macro. Will be
made into a function soon.
(GstMessage): Add a state_changed structure to the union. The
union will die soon in favor of a single GstStructure tho.
(gst_message_new_state_changed): New API.
* gst/gstmessage.c (gst_message_new_state_changed): New API.
* tools/gst-launch.c (check_intr): Set the state of the pipeline
to PAUSED here; the poll will catch the state change.
(event_loop): New function, polls the pipeline bus for events. Can
block until eos/error/state change, or just handle the pending
events.
(main): Changed to use event_loop instead of running a main loop.
* gst/gstbus.h (gst_bus_poll): Added.
(gst_bus_peek): Return non-const; the message is refcounted
anyway.
* gst/gstbus.c (gst_bus_init): Replace the GAsyncQueue with a
GQueue+mutex to allow for _peek. (The wake-up functionality
provided by GAsyncQueue is already done by our socketpair.) All
queue users changed to lock, operate, and unlock.
(gst_bus_post): Check the retval of write(2) and handle errno.
(gst_bus_peek): Implemented.
(gst_bus_pop, gst_bus_peek, bus_callback): Because the socketpair
is used to wake up the GSource, read off the character in the
GSource handler and not in pop/peek. This is because a peek will
require a pop in the future, and you can't read off the char
twice. Deal with errno in the read.
(bus_callback): Interpret the handler return value as whether or
not to pop the message from the bus.
(poll_handler, poll_timeout, gst_bus_poll): New API. gst_bus_poll
is meant to replace the while(gst_bin_iterate()) idiom.
2005-02-21 11:54:55 +00:00
|
|
|
GstMessageType gst_bus_poll (GstBus *bus, GstMessageType events,
|
|
|
|
GstClockTimeDiff timeout);
|
|
|
|
|
2004-12-08 18:05:14 +00:00
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __GST_BUS_H__ */
|