element: API: Add GstElement::post_message() vfunc
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 16 Oct 2012 10:31:50 +0000 (12:31 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 16 Oct 2012 10:35:56 +0000 (12:35 +0200)
Conflicts:
gst/gstelement.h

gst/gstelement.c
gst/gstelement.h

index c8205df..b4b87f4 100644 (file)
@@ -130,6 +130,9 @@ static GstStateChangeReturn gst_element_set_state_func (GstElement * element,
 static gboolean gst_element_set_clock_func (GstElement * element,
     GstClock * clock);
 static void gst_element_set_bus_func (GstElement * element, GstBus * bus);
+static gboolean gst_element_post_message_default (GstElement * element,
+    GstMessage * message);
+
 
 static gboolean gst_element_default_send_event (GstElement * element,
     GstEvent * event);
@@ -235,6 +238,7 @@ gst_element_class_init (GstElementClass * klass)
   klass->query = GST_DEBUG_FUNCPTR (gst_element_default_query);
   klass->send_event = GST_DEBUG_FUNCPTR (gst_element_default_send_event);
   klass->numpadtemplates = 0;
+  klass->post_message = GST_DEBUG_FUNCPTR (gst_element_post_message_default);
 
   klass->elementfactory = NULL;
 }
@@ -1662,22 +1666,8 @@ gst_element_query (GstElement * element, GstQuery * query)
   return result;
 }
 
-/**
- * gst_element_post_message:
- * @element: a #GstElement posting the message
- * @message: (transfer full): a #GstMessage to post
- *
- * Post a message on the element's #GstBus. This function takes ownership of the
- * message; if you want to access the message after this call, you should add an
- * additional reference before calling.
- *
- * Returns: %TRUE if the message was successfully posted. The function returns
- * %FALSE if the element did not have a bus.
- *
- * MT safe.
- */
-gboolean
-gst_element_post_message (GstElement * element, GstMessage * message)
+static gboolean
+gst_element_post_message_default (GstElement * element, GstMessage * message)
 {
   GstBus *bus;
   gboolean result = FALSE;
@@ -1713,6 +1703,34 @@ no_bus:
 }
 
 /**
+ * gst_element_post_message:
+ * @element: a #GstElement posting the message
+ * @message: (transfer full): a #GstMessage to post
+ *
+ * Post a message on the element's #GstBus. This function takes ownership of the
+ * message; if you want to access the message after this call, you should add an
+ * additional reference before calling.
+ *
+ * Returns: %TRUE if the message was successfully posted. The function returns
+ * %FALSE if the element did not have a bus.
+ *
+ * MT safe.
+ */
+gboolean
+gst_element_post_message (GstElement * element, GstMessage * message)
+{
+  GstElementClass *klass;
+
+  g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
+
+  klass = GST_ELEMENT_GET_CLASS (element);
+  if (klass->post_message)
+    return klass->post_message (element, message);
+
+  return FALSE;
+}
+
+/**
  * _gst_element_error_printf:
  * @format: the printf-like format to use, or %NULL
  *
index 725dc34..df71720 100644 (file)
@@ -591,6 +591,8 @@ struct _GstElement
  * @send_event: send a #GstEvent to the element
  * @query: perform a #GstQuery on the element
  * @state_changed: called immediately after a new state was set.
+ * @post_message: called when a message is posted on the element. Chain up to
+ *                the parent class' handler to have it posted on the bus.
  *
  * GStreamer element class. Override the vmethods to implement the element
  * functionality.
@@ -645,8 +647,10 @@ struct _GstElementClass
 
   gboolean              (*query)                (GstElement *element, GstQuery *query);
 
+  gboolean              (*post_message)         (GstElement *element, GstMessage *message);
+
   /*< private >*/
-  gpointer _gst_reserved[GST_PADDING_LARGE];
+  gpointer _gst_reserved[GST_PADDING_LARGE-1];
 };
 
 /* element class pad templates */