diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2013-07-14 10:55:08 +0200 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2013-07-14 10:55:08 +0200 |
commit | 01f23673f675e49cdadf2007671a14835c7b2698 (patch) | |
tree | b4abab458518fbaef118295ef64082144385a815 /gst/gstelement.c | |
parent | e3751287e37561e9014ba3752a5db6ee4d682c25 (diff) |
Imported Upstream version 1.1.2upstream/1.1.2
Diffstat (limited to 'gst/gstelement.c')
-rw-r--r-- | gst/gstelement.c | 107 |
1 files changed, 89 insertions, 18 deletions
diff --git a/gst/gstelement.c b/gst/gstelement.c index 02d6ebd..587de1b 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -16,8 +16,8 @@ * * 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. + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ /** @@ -97,6 +97,10 @@ #include "gst-i18n-lib.h" #include "glib-compat-private.h" +#ifndef GST_DISABLE_GST_DEBUG +#include "printf/printf.h" +#endif + /* Element signals and args */ enum { @@ -132,7 +136,8 @@ static gboolean gst_element_set_clock_func (GstElement * element, static void gst_element_set_bus_func (GstElement * element, GstBus * bus); static gboolean gst_element_post_message_default (GstElement * element, GstMessage * message); - +static void gst_element_set_context_func (GstElement * element, + GstContext * context); static gboolean gst_element_default_send_event (GstElement * element, GstEvent * event); @@ -239,6 +244,7 @@ gst_element_class_init (GstElementClass * klass) 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->set_context = GST_DEBUG_FUNCPTR (gst_element_set_context_func); klass->elementfactory = NULL; } @@ -1121,8 +1127,7 @@ gst_element_iterate_pad_list (GstElement * element, GList ** padlist) * The order of pads returned by the iterator will be the order in which * the pads were added to the element. * - * Returns: (transfer full): the #GstIterator of #GstPad. Unref each pad - * after use. + * Returns: (transfer full): the #GstIterator of #GstPad. * * MT safe. */ @@ -1143,8 +1148,7 @@ gst_element_iterate_pads (GstElement * element) * The order of pads returned by the iterator will be the order in which * the pads were added to the element. * - * Returns: (transfer full): the #GstIterator of #GstPad. Unref each pad - * after use. + * Returns: (transfer full): the #GstIterator of #GstPad. * * MT safe. */ @@ -1165,8 +1169,7 @@ gst_element_iterate_src_pads (GstElement * element) * The order of pads returned by the iterator will be the order in which * the pads were added to the element. * - * Returns: (transfer full): the #GstIterator of #GstPad. Unref each pad - * after use. + * Returns: (transfer full): the #GstIterator of #GstPad. * * MT safe. */ @@ -1650,20 +1653,19 @@ gst_element_default_query (GstElement * element, GstQuery * query) gboolean gst_element_query (GstElement * element, GstQuery * query) { - GstElementClass *oclass; - gboolean result = FALSE; + GstElementClass *klass; g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); g_return_val_if_fail (query != NULL, FALSE); - oclass = GST_ELEMENT_GET_CLASS (element); - - if (oclass->query) { + klass = GST_ELEMENT_GET_CLASS (element); + if (klass->query) { GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "send query on element %s", GST_ELEMENT_NAME (element)); - result = oclass->query (element, query); + return klass->query (element, query); } - return result; + + return FALSE; } static gboolean @@ -1722,6 +1724,7 @@ gst_element_post_message (GstElement * element, GstMessage * message) GstElementClass *klass; g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); + g_return_val_if_fail (message != NULL, FALSE); klass = GST_ELEMENT_GET_CLASS (element); if (klass->post_message) @@ -1746,6 +1749,7 @@ _gst_element_error_printf (const gchar * format, ...) { va_list args; gchar *buffer; + int len; if (format == NULL) return NULL; @@ -1753,8 +1757,14 @@ _gst_element_error_printf (const gchar * format, ...) return NULL; va_start (args, format); - buffer = g_strdup_vprintf (format, args); + + len = __gst_vasprintf (&buffer, format, args); + va_end (args); + + if (len < 0) + buffer = NULL; + return buffer; } @@ -2428,7 +2438,8 @@ only_async_start: * element will perform the remainder of the state change asynchronously in * another thread. * An application can use gst_element_get_state() to wait for the completion - * of the state change or it can wait for a state change message on the bus. + * of the state change or it can wait for a %GST_MESSAGE_ASYNC_DONE or + * %GST_MESSAGE_STATE_CHANGED on the bus. * * State changes to %GST_STATE_READY or %GST_STATE_NULL never return * #GST_STATE_CHANGE_ASYNC. @@ -2904,6 +2915,7 @@ gst_element_dispose (GObject * object) bus_p = &element->bus; gst_object_replace ((GstObject **) clock_p, NULL); gst_object_replace ((GstObject **) bus_p, NULL); + gst_context_replace (&element->context, NULL); GST_OBJECT_UNLOCK (element); GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "parent class dispose"); @@ -3013,3 +3025,62 @@ gst_element_get_bus (GstElement * element) return result; } + +static void +gst_element_set_context_func (GstElement * element, GstContext * context) +{ + GST_OBJECT_LOCK (element); + gst_context_replace (&element->context, context); + GST_OBJECT_UNLOCK (element); +} + +/** + * gst_element_set_context: + * @element: a #GstElement to set the context of. + * @context: (transfer none): the #GstContext to set. + * + * Sets the context of the element. Increases the refcount of the context. + * + * MT safe. + */ +void +gst_element_set_context (GstElement * element, GstContext * context) +{ + GstElementClass *oclass; + + g_return_if_fail (GST_IS_ELEMENT (element)); + + oclass = GST_ELEMENT_GET_CLASS (element); + + GST_CAT_DEBUG_OBJECT (GST_CAT_CONTEXT, element, + "set context %p %" GST_PTR_FORMAT, context, + gst_context_get_structure (context)); + + if (oclass->set_context) + oclass->set_context (element, context); +} + +/** + * gst_element_get_context: + * @element: a #GstElement to get the context from. + * + * Gets the current context of the element. + * + * MT safe. + * + * Returns: (transfer full): The current context of the element + */ +GstContext * +gst_element_get_context (GstElement * element) +{ + GstContext *context = NULL; + + g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); + + GST_OBJECT_LOCK (element); + if (element->context) + context = gst_context_ref (element->context); + GST_OBJECT_UNLOCK (element); + + return context; +} |