* Core and plug-in writers can add and remove pads with gst_element_add_pad()
* and gst_element_remove_pad().
*
- * A pad of an element can be retrieved by name with gst_element_get_pad().
+ * An existing pad of an element can be retrieved by name with
+ * gst_element_get_static_pad(). A new dynamic pad can be created using
+ * gst_element_request_pad() with a #GstPadTemplate or
+ * gst_element_get_request_pad() with the template name such as "src_\%d".
* An iterator of all pads can be retrieved with gst_element_iterate_pads().
*
* Elements can be linked through their pads.
static guint gst_element_signals[LAST_SIGNAL] = { 0 };
/* this is used in gstelementfactory.c:gst_element_register() */
-GQuark _gst_elementclass_factory = 0;
+GQuark __gst_elementclass_factory = 0;
GType
gst_element_get_type (void)
_type = g_type_register_static (GST_TYPE_OBJECT, "GstElement",
&element_info, G_TYPE_FLAG_ABSTRACT);
- _gst_elementclass_factory =
+ __gst_elementclass_factory =
g_quark_from_static_string ("GST_ELEMENTCLASS_FACTORY");
g_once_init_leave (&gst_element_type, _type);
}
gst_element_class_init (GstElementClass * klass)
{
GObjectClass *gobject_class;
- GstObjectClass *gstobject_class;
gobject_class = (GObjectClass *) klass;
- gstobject_class = (GstObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
* the details in class_init instead of base_init */
element_class->metadata =
element_class->metadata ? gst_structure_copy (element_class->metadata) :
- gst_structure_empty_new ("metadata");
+ gst_structure_new_empty ("metadata");
/* Copy the pad templates so elements inherit them
* from their base class but elements can add pad templates in class_init
* instead of base_init.
*/
- /* FIXME: Do we consider GstPadTemplates as immutable? If so we can
- * simply ref them instead of copying.
- */
padtemplates = g_list_copy (element_class->padtemplates);
for (node = padtemplates; node != NULL; node = node->next) {
GstPadTemplate *tmpl = (GstPadTemplate *) node->data;
- node->data = gst_pad_template_new (tmpl->name_template,
- tmpl->direction, tmpl->presence, gst_caps_copy (tmpl->caps));
+ gst_object_ref (tmpl);
}
element_class->padtemplates = padtemplates;
/* set the factory, see gst_element_register() */
element_class->elementfactory =
g_type_get_qdata (G_TYPE_FROM_CLASS (element_class),
- _gst_elementclass_factory);
+ __gst_elementclass_factory);
GST_DEBUG ("type %s : factory %p", G_OBJECT_CLASS_NAME (element_class),
element_class->elementfactory);
}
GST_STATE_PENDING (element) = GST_STATE_VOID_PENDING;
GST_STATE_RETURN (element) = GST_STATE_CHANGE_SUCCESS;
- /* FIXME 0.11: Store this directly in the instance struct */
- element->state_lock = g_slice_new (GStaticRecMutex);
- g_static_rec_mutex_init (element->state_lock);
+ g_static_rec_mutex_init (&element->state_lock);
element->state_cond = g_cond_new ();
}
/* ERRORS */
not_our_pad:
{
- /* FIXME, locking order? */
+ /* locking order is element > pad */
+ GST_OBJECT_UNLOCK (pad);
+
GST_OBJECT_LOCK (element);
+ GST_OBJECT_LOCK (pad);
g_critical ("Padname %s:%s does not belong to element %s when removing",
GST_DEBUG_PAD_NAME (pad), GST_ELEMENT_NAME (element));
- GST_OBJECT_UNLOCK (element);
GST_OBJECT_UNLOCK (pad);
+ GST_OBJECT_UNLOCK (element);
return FALSE;
}
}
* @element: a #GstElement to find a request pad of.
* @name: the name of the request #GstPad to retrieve.
*
- * Retrieves a pad from the element by name. This version only retrieves
- * request pads. The pad should be released with
+ * Retrieves a pad from the element by name (e.g. "src_\%d"). This version only
+ * retrieves request pads. The pad should be released with
* gst_element_release_request_pad().
*
* This method is slow and will be deprecated in the future. New code should
* request. Can be %NULL.
*
* Retrieves a request pad from the element according to the provided template.
+ * Pad templates can be looked up using
+ * gst_element_factory_get_static_pad_templates().
*
* If the @caps are specified and the element implements thew new
* request_new_pad_full virtual method, the element will use them to select
return _gst_element_request_pad (element, templ, name, caps);
}
-/**
- * gst_element_get_pad:
- * @element: a #GstElement.
- * @name: the name of the pad to retrieve.
- *
- * Retrieves a pad from @element by name. Tries gst_element_get_static_pad()
- * first, then gst_element_get_request_pad().
- *
- * Deprecated: This function is deprecated as it's unclear if the reference
- * to the result pad should be released with gst_object_unref() in case of a static pad
- * or gst_element_release_request_pad() in case of a request pad.
- * Use gst_element_get_static_pad() or gst_element_get_request_pad() instead.
- *
- * Returns: (transfer full): the #GstPad if found, otherwise %NULL. Unref or Release after usage,
- * depending on the type of the pad.
- */
-#ifndef GST_REMOVE_DEPRECATED
-#ifdef GST_DISABLE_DEPRECATED
-GstPad *gst_element_get_pad (GstElement * element, const gchar * name);
-#endif
-GstPad *
-gst_element_get_pad (GstElement * element, const gchar * name)
-{
- GstPad *pad;
-
- g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- pad = gst_element_get_static_pad (element, name);
- if (!pad)
- pad = gst_element_get_request_pad (element, name);
-
- return pad;
-}
-#endif /* GST_REMOVE_DEPRECATED */
-
static GstIterator *
gst_element_iterate_pad_list (GstElement * element, GList ** padlist)
{
* gst_element_iterate_pads:
* @element: a #GstElement to iterate pads of.
*
- * Retrieves an iterattor of @element's pads. The iterator should
- * be freed after usage.
+ * Retrieves an iterator of @element's pads. The iterator should
+ * be freed after usage. Also more specialized iterators exists such as
+ * gst_element_iterate_src_pads() or gst_element_iterate_sink_pads().
*
* Returns: (transfer full): the #GstIterator of #GstPad. Unref each pad
* after use.
template_list = g_list_next (template_list);
}
+ /* Take ownership of the floating ref */
+ g_object_ref_sink (templ);
+
klass->padtemplates = g_list_append (klass->padtemplates, templ);
klass->numpadtemplates++;
}
}
/**
+ * gst_element_class_get_metadata:
+ * @klass: class to get metadata for
+ * @key: the key to get
+ *
+ * Get metadata with @key in @klass.
+ *
+ * Returns: the metadata for @key.
+ */
+const gchar *
+gst_element_class_get_metadata (GstElementClass * klass, const gchar * key)
+{
+ g_return_val_if_fail (GST_IS_ELEMENT_CLASS (klass), NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+
+ return gst_structure_get_string ((GstStructure *) klass->metadata, key);
+}
+
+/**
* gst_element_class_get_pad_template_list:
* @element_class: a #GstElementClass to get pad templates of.
*
return result;
}
-/**
- * gst_element_get_query_types:
- * @element: a #GstElement to query
- *
- * Get an array of query types from the element.
- * If the element doesn't implement a query types function,
- * the query will be forwarded to the peer of a random linked sink pad.
- *
- * Returns: An array of #GstQueryType elements that should not
- * be freed or modified.
- *
- * MT safe.
- */
-const GstQueryType *
-gst_element_get_query_types (GstElement * element)
-{
- GstElementClass *oclass;
- const GstQueryType *result = NULL;
-
- g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
-
- oclass = GST_ELEMENT_GET_CLASS (element);
-
- if (oclass->get_query_types) {
- result = oclass->get_query_types (element);
- } else {
- GstPad *pad = gst_element_get_random_pad (element, TRUE, GST_PAD_SINK);
-
- if (pad) {
- GstPad *peer = gst_pad_get_peer (pad);
-
- if (peer) {
- result = gst_pad_get_query_types (peer);
-
- gst_object_unref (peer);
- }
- gst_object_unref (pad);
- }
- }
- return result;
-}
-
static gboolean
gst_element_default_query (GstElement * element, GstQuery * query)
{
if (ret == GST_STATE_CHANGE_FAILURE)
goto done;
- /* we got no_preroll, report immediatly */
+ /* we got no_preroll, report immediately */
if (ret == GST_STATE_CHANGE_NO_PREROLL)
goto done;
/**
* gst_element_lost_state:
* @element: a #GstElement the state is lost of
- * @new_base_time: if a new base time should be distributed
*
* Brings the element to the lost state. The current state of the
* element is copied to the pending state so that any call to
* gst_element_get_state() will return %GST_STATE_CHANGE_ASYNC.
*
- * An ASYNC_START message is posted with indication to distribute a new
- * base_time to the element when @new_base_time is %TRUE.
- * If the element was PLAYING, it will go to PAUSED. The element
- * will be restored to its PLAYING state by the parent pipeline when it
- * prerolls again.
+ * An ASYNC_START message is posted. If the element was PLAYING, it will
+ * go to PAUSED. The element will be restored to its PLAYING state by
+ * the parent pipeline when it prerolls again.
*
* This is mostly used for elements that lost their preroll buffer
* in the %GST_STATE_PAUSED or %GST_STATE_PLAYING state after a flush,
* plugins or applications.
*/
void
-gst_element_lost_state (GstElement * element, gboolean new_base_time)
+gst_element_lost_state (GstElement * element)
{
GstState old_state, new_state;
GstMessage *message;
GST_STATE_NEXT (element) = new_state;
GST_STATE_PENDING (element) = new_state;
GST_STATE_RETURN (element) = GST_STATE_CHANGE_ASYNC;
- if (new_base_time)
- GST_ELEMENT_START_TIME (element) = 0;
GST_OBJECT_UNLOCK (element);
_priv_gst_element_state_changed (element, new_state, new_state, new_state);
- message =
- gst_message_new_async_start (GST_OBJECT_CAST (element), new_base_time);
+ message = gst_message_new_async_start (GST_OBJECT_CAST (element));
gst_element_post_message (element, message);
return;
{
GST_OBJECT_UNLOCK (element);
- message = gst_message_new_async_start (GST_OBJECT_CAST (element), TRUE);
+ message = gst_message_new_async_start (GST_OBJECT_CAST (element));
gst_element_post_message (element, message);
return;
}
GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "finalize");
- GST_STATE_LOCK (element);
- if (element->state_cond)
- g_cond_free (element->state_cond);
- element->state_cond = NULL;
- GST_STATE_UNLOCK (element);
- g_static_rec_mutex_free (element->state_lock);
- g_slice_free (GStaticRecMutex, element->state_lock);
- element->state_lock = NULL;
+ g_cond_free (element->state_cond);
+ g_static_rec_mutex_free (&element->state_lock);
GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "finalize parent");