Commit 5209b1b0 authored by Wim Taymans's avatar Wim Taymans

Make message handling overridable.

Original commit message from CVS:
* docs/design/part-TODO.txt:
* gst/gstbin.c: (gst_bin_class_init), (gst_bin_provide_clock_func),
(gst_bin_add_func), (gst_bin_remove_func), (bin_bus_handler),
(gst_bin_handle_message_func):
* gst/gstbin.h:
Make message handling overridable.
parent 5061adaf
2005-11-19 Wim Taymans <wim@fluendo.com>
* docs/design/part-TODO.txt:
* gst/gstbin.c: (gst_bin_class_init), (gst_bin_provide_clock_func),
(gst_bin_add_func), (gst_bin_remove_func), (bin_bus_handler),
(gst_bin_handle_message_func):
* gst/gstbin.h:
Make message handling overridable.
2005-11-19 Andy Wingo <wingo@pobox.com>
* gst/gstpad.h (GST_PAD_IS_USABLE): Removed. Fixes #321235.
......
......@@ -9,17 +9,6 @@ API/ABI
- convert framerate to GstFraction in GstCaps.
- implement latency calculation for live sources.
- implement master/slave clocks.
- implement QOS.
- implement BUFFERSIZE.
- make bin_bus_handler a vmethod so subclasses can use their own implementation
or chain to the parent.
- make it possible to seek on other formats than bytes in basesrc.
- GstFormat, GstQuery quarks, get_name.
......@@ -47,7 +36,13 @@ API/ABI
IMPLEMENTATION
--------------
- implement clock selection as explained in part-gstpipeline.txt.
- implement latency calculation for live sources.
- implement master/slave clocks.
- implement QOS.
- implement BUFFERSIZE.
DESIGN
......
......@@ -147,6 +147,7 @@ static void gst_bin_set_index_func (GstElement * element, GstIndex * index);
static GstClock *gst_bin_provide_clock_func (GstElement * element);
static void gst_bin_set_clock_func (GstElement * element, GstClock * clock);
static void gst_bin_handle_message_func (GstBin * bin, GstMessage * message);
static gboolean gst_bin_send_event (GstElement * element, GstEvent * event);
static GstBusSyncReply bin_bus_handler (GstBus * bus,
GstMessage * message, GstBin * bin);
......@@ -336,6 +337,7 @@ gst_bin_class_init (GstBinClass * klass)
klass->add_element = GST_DEBUG_FUNCPTR (gst_bin_add_func);
klass->remove_element = GST_DEBUG_FUNCPTR (gst_bin_remove_func);
klass->handle_message = GST_DEBUG_FUNCPTR (gst_bin_handle_message_func);
GST_DEBUG ("creating bin thread pool");
err = NULL;
......@@ -497,7 +499,7 @@ gst_bin_provide_clock_func (GstElement * element)
}
gst_object_replace ((GstObject **) & bin->provided_clock,
(GstObject *) result);
gst_object_replace ((GstObject **) & bin->ABI.clock_provider,
gst_object_replace ((GstObject **) & bin->clock_provider,
(GstObject *) provider);
bin->clock_dirty = FALSE;
GST_DEBUG_OBJECT (bin, "provided new clock %p", result);
......@@ -871,7 +873,7 @@ gst_bin_remove_func (GstBin * bin, GstElement * element)
/* if the clock provider for this element is removed, we lost
* the clock as well, we need to inform the parent of this
* so that it can select a new clock */
if (bin->ABI.clock_provider == element) {
if (bin->clock_provider == element) {
GST_DEBUG_OBJECT (bin, "element \"%s\" provided the clock", elem_name);
bin->clock_dirty = TRUE;
clock_message =
......@@ -1839,6 +1841,21 @@ gst_bin_recalc_func (GstBin * bin, gpointer data)
*/
static GstBusSyncReply
bin_bus_handler (GstBus * bus, GstMessage * message, GstBin * bin)
{
GstBinClass *bclass;
bclass = GST_BIN_GET_CLASS (bin);
if (bclass->handle_message)
bclass->handle_message (bin, message);
else
gst_message_unref (message);
return GST_BUS_DROP;
}
static void
gst_bin_handle_message_func (GstBin * bin, GstMessage * message)
{
GST_DEBUG_OBJECT (bin, "[msg %p] handling child message of type %s",
message, gst_message_type_get_name (GST_MESSAGE_TYPE (message)));
......@@ -1994,14 +2011,14 @@ bin_bus_handler (GstBus * bus, GstMessage * message, GstBin * bin)
goto forward;
}
return GST_BUS_DROP;
return;
forward:
{
/* Send all other messages upward */
GST_DEBUG_OBJECT (bin, "posting message upward");
gst_element_post_message (GST_ELEMENT_CAST (bin), message);
return GST_BUS_DROP;
return;
}
}
......
......@@ -88,6 +88,7 @@ typedef struct _GstBinClass GstBinClass;
* @state_dirty: the bin needs to recalculate its state
* @clock_dirty: the bin needs to select a new clock
* @provided_clock: the last clock selected
* @clock_provider: the element that provided @provided_clock
*
* The GstBin base class. Subclasses can access these fields provided
* the LOCK is taken.
......@@ -110,14 +111,10 @@ struct _GstBin {
gboolean clock_dirty;
GstClock *provided_clock;
GstElement *clock_provider;
/*< private >*/
union {
struct {
GstElement *clock_provider;
} ABI;
gpointer _gst_reserved[GST_PADDING+1-1];
};
gpointer _gst_reserved[GST_PADDING];
};
/**
......@@ -125,9 +122,13 @@ struct _GstBin {
* @parent_class: bin parent class
* @add_element: method to add an element to a bin
* @remove_element: method to remove an element from a bin
* @handle_message: method to handle a message from the children
*
* Subclasses can override the @add_element and @remove_element to
* update the list of children in the bin.
*
* The @handle_message method can be overriden to implement custom
* message handling.
*/
struct _GstBinClass {
GstElementClass parent_class;
......@@ -144,6 +145,8 @@ struct _GstBinClass {
gboolean (*add_element) (GstBin *bin, GstElement *element);
gboolean (*remove_element) (GstBin *bin, GstElement *element);
void (*handle_message) (GstBin *bin, GstMessage *message);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment