* 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.
GstState * state, GstState * pending, GstClockTime timeout);
static GstStateChangeReturn gst_element_set_state_func (GstElement * element,
GstState state);
+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_default_send_event (GstElement * element,
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);
klass->change_state = GST_DEBUG_FUNCPTR (gst_element_change_state_func);
klass->set_state = GST_DEBUG_FUNCPTR (gst_element_set_state_func);
klass->get_state = GST_DEBUG_FUNCPTR (gst_element_get_state_func);
+ klass->set_clock = GST_DEBUG_FUNCPTR (gst_element_set_clock_func);
klass->set_bus = GST_DEBUG_FUNCPTR (gst_element_set_bus_func);
klass->query = GST_DEBUG_FUNCPTR (gst_element_default_query);
klass->send_event = GST_DEBUG_FUNCPTR (gst_element_default_send_event);
* 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
/* 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 ();
}
return result;
}
+static gboolean
+gst_element_set_clock_func (GstElement * element, GstClock * clock)
+{
+ GstClock **clock_p;
+
+ GST_OBJECT_LOCK (element);
+ clock_p = &element->clock;
+ gst_object_replace ((GstObject **) clock_p, (GstObject *) clock);
+ GST_OBJECT_UNLOCK (element);
+
+ return TRUE;
+}
+
/**
* gst_element_set_clock:
* @element: a #GstElement to set the clock for.
gst_element_set_clock (GstElement * element, GstClock * clock)
{
GstElementClass *oclass;
- gboolean res = TRUE;
- GstClock **clock_p;
+ gboolean res = FALSE;
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
g_return_val_if_fail (clock == NULL || GST_IS_CLOCK (clock), FALSE);
if (oclass->set_clock)
res = oclass->set_clock (element, clock);
- if (res) {
- /* only update the clock pointer if the element accepted the clock */
- GST_OBJECT_LOCK (element);
- clock_p = &element->clock;
- gst_object_replace ((GstObject **) clock_p, (GstObject *) clock);
- GST_OBJECT_UNLOCK (element);
- }
return res;
}
GST_CAT_INFO_OBJECT (GST_CAT_ELEMENT_PADS, element, "adding pad '%s'",
GST_STR_NULL (pad_name));
flushing = GST_PAD_IS_FLUSHING (pad);
+ GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_NEED_PARENT);
GST_OBJECT_UNLOCK (pad);
/* then check to see if there's already a pad by that name here */
/* 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.
- *
- * If the @caps are specified and the element implements thew new
- * request_new_pad_full virtual method, the element will use them to select
- * which pad to create.
+ * Pad templates can be looked up using
+ * gst_element_factory_get_static_pad_templates().
*
* The pad should be released with gst_element_release_request_pad().
*
* 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.
}
/* Take ownership of the floating ref */
- g_object_ref_sink (templ);
+ gst_object_ref_sink (templ);
klass->padtemplates = g_list_append (klass->padtemplates, templ);
klass->numpadtemplates++;
*
* Returns: the metadata for @key.
*/
-G_CONST_RETURN gchar *
+const gchar *
gst_element_class_get_metadata (GstElementClass * klass, const gchar * key)
{
g_return_val_if_fail (GST_IS_ELEMENT_CLASS (klass), NULL);
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "send %s event on element %s",
GST_EVENT_TYPE_NAME (event), GST_ELEMENT_NAME (element));
result = oclass->send_event (element, event);
- } else {
- result = gst_element_default_send_event (element, event);
}
GST_STATE_UNLOCK (element);
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)
{
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "send query on element %s",
GST_ELEMENT_NAME (element));
result = oclass->query (element, query);
- } else {
- result = gst_element_default_query (element, query);
}
return result;
}
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");