summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2012-10-16 12:31:50 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-10-16 12:31:50 +0200
commit09743e0ac935389f35202798acab329e9d93381c (patch)
treeacedd306c0874f7dc6518fb518bc6f3c228a6bb9
parentbbec3d4e2f4f0ce4a20fd7ce2b1bcae257df01b7 (diff)
downloadgstreamer-09743e0ac935389f35202798acab329e9d93381c.tar.gz
element: API: Add GstElement::post_message() vfunc
-rw-r--r--gst/gstelement.c50
-rw-r--r--gst/gstelement.h6
2 files changed, 39 insertions, 17 deletions
diff --git a/gst/gstelement.c b/gst/gstelement.c
index c03a5c9fe9..fba84c6981 100644
--- a/gst/gstelement.c
+++ b/gst/gstelement.c
@@ -141,6 +141,9 @@ static GstStateChangeReturn gst_element_get_state_func (GstElement * element,
static GstStateChangeReturn gst_element_set_state_func (GstElement * element,
GstState state);
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);
@@ -261,6 +264,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;
}
@@ -1819,22 +1823,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;
@@ -1870,6 +1860,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
*
diff --git a/gst/gstelement.h b/gst/gstelement.h
index 5c3286fb40..1c6c6a9024 100644
--- a/gst/gstelement.h
+++ b/gst/gstelement.h
@@ -604,6 +604,8 @@ struct _GstElement
* @query: perform a #GstQuery on the element
* @request_new_pad_full: called when a new pad is requested. Since: 0.10.32.
* @state_changed: called immediately after a new state was set. Since: 0.10.36.
+ * @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. Since: 0.10.37.
*
* GStreamer element class. Override the vmethods to implement the element
* functionality.
@@ -674,8 +676,10 @@ struct _GstElementClass
void (*state_changed) (GstElement *element, GstState oldstate,
GstState newstate, GstState pending);
+ gboolean (*post_message) (GstElement *element, GstMessage *message);
+
/*< private >*/
- gpointer _gst_reserved[GST_PADDING-3];
+ gpointer _gst_reserved[GST_PADDING-4];
};
/* element class pad templates */