* @name: the name of the argument to set
* @value: the string value to set
*
- * Convertes the string value to the type of the objects argument and
+ * Converts the string value to the type of the objects argument and
* sets the argument with it.
*
* Note that this function silently returns if @object has no property named
g_value_init (&v, value_type);
/* special case for element <-> xml (de)serialisation */
- if (GST_VALUE_HOLDS_STRUCTURE (&v) && strcmp (value, "NULL") == 0) {
+ if (value_type == GST_TYPE_STRUCTURE && strcmp (value, "NULL") == 0) {
g_value_set_boxed (&v, NULL);
goto done;
}
* Retrieves a pad template from @element that is compatible with @compattempl.
* Pads from compatible templates can be linked together.
*
- * Returns: (transfer none): a compatible #GstPadTemplate, or NULL if none
- * was found. No unreferencing is necessary.
+ * Returns: (transfer none) (nullable): a compatible #GstPadTemplate,
+ * or %NULL if none was found. No unreferencing is necessary.
*/
GstPadTemplate *
gst_element_get_compatible_pad_template (GstElement * element,
* #GST_PAD_REQUEST, requests a new pad. Can return %NULL for #GST_PAD_SOMETIMES
* templates.
*
- * Returns: (transfer full): the #GstPad, or NULL if one could not be found
- * or created.
+ * Returns: (transfer full) (nullable): the #GstPad, or %NULL if one
+ * could not be found or created.
*/
static GstPad *
gst_element_get_pad_from_template (GstElement * element, GstPadTemplate * templ)
* Requests a pad from @element. The returned pad should be unlinked and
* compatible with @templ. Might return an existing pad, or request a new one.
*
- * Returns: a #GstPad, or %NULL if one could not be found or created.
+ * Returns: (nullable): a #GstPad, or %NULL if one could not be found
+ * or created.
*/
static GstPad *
gst_element_request_compatible_pad (GstElement * element,
static gboolean
gst_pad_check_link (GstPad * srcpad, GstPad * sinkpad)
{
- /* FIXME This function is gross. It's almost a direct copy of
- * gst_pad_link_filtered(). Any decent programmer would attempt
- * to merge the two functions, which I will do some day. --ds
- */
-
/* generic checks */
g_return_val_if_fail (GST_IS_PAD (srcpad), FALSE);
g_return_val_if_fail (GST_IS_PAD (sinkpad), FALSE);
GST_CAT_INFO (GST_CAT_PADS, "trying to link %s:%s and %s:%s",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
- /* FIXME: shouldn't we convert this to g_return_val_if_fail? */
if (GST_PAD_PEER (srcpad) != NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Source pad %s:%s has a peer, failed",
GST_DEBUG_PAD_NAME (srcpad));
* and if none can be found, it will request a compatible REQUEST pad by looking
* at the templates of @element.
*
- * Returns: (transfer full): the #GstPad to which a link can be made, or %NULL
- * if one cannot be found. gst_object_unref() after usage.
+ * Returns: (transfer full) (nullable): the #GstPad to which a link
+ * can be made, or %NULL if one cannot be found. gst_object_unref()
+ * after usage.
*/
GstPad *
gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
/* try to create a new one */
/* requesting is a little crazy, we need a template. Let's create one */
- /* FIXME: why not gst_pad_get_pad_template (pad); */
templcaps = gst_pad_query_caps (pad, NULL);
+ if (caps) {
+ GstCaps *inter = gst_caps_intersect (templcaps, caps);
+
+ gst_caps_unref (templcaps);
+ templcaps = inter;
+ }
templ = gst_pad_template_new ((gchar *) GST_PAD_NAME (pad),
GST_PAD_DIRECTION (pad), GST_PAD_ALWAYS, templcaps);
gst_caps_unref (templcaps);
/* we need to setup some ghost pads */
root = find_common_root (e1, e2);
if (!root) {
- g_warning ("Trying to connect elements that don't share a common "
- "ancestor: %s and %s", GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (e2));
+ if (GST_OBJECT_PARENT (e1) == NULL)
+ g_warning ("Trying to link elements %s and %s that don't share a common "
+ "ancestor: %s hasn't been added to a bin or pipeline, but %s is in %s",
+ GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (e2),
+ GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (e2),
+ GST_ELEMENT_NAME (GST_OBJECT_PARENT (e2)));
+ else if (GST_OBJECT_PARENT (e2) == NULL)
+ g_warning ("Trying to link elements %s and %s that don't share a common "
+ "ancestor: %s hasn't been added to a bin or pipeline, and %s is in %s",
+ GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (e2),
+ GST_ELEMENT_NAME (e2), GST_ELEMENT_NAME (e1),
+ GST_ELEMENT_NAME (GST_OBJECT_PARENT (e1)));
+ else
+ g_warning ("Trying to link elements %s and %s that don't share a common "
+ "ancestor: %s is in %s, and %s is in %s",
+ GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (e2),
+ GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (GST_OBJECT_PARENT (e1)),
+ GST_ELEMENT_NAME (e2), GST_ELEMENT_NAME (GST_OBJECT_PARENT (e2)));
return FALSE;
}
return ret;
}
+static void
+release_and_unref_pad (GstElement * element, GstPad * pad, gboolean requestpad)
+{
+ if (pad) {
+ if (requestpad)
+ gst_element_release_request_pad (element, pad);
+ gst_object_unref (pad);
+ }
+}
+
/**
* gst_element_link_pads_full:
* @src: a #GstElement containing the source pad.
* @srcpadname: (allow-none): the name of the #GstPad in source element
- * or NULL for any pad.
+ * or %NULL for any pad.
* @dest: (transfer none): the #GstElement containing the destination pad.
* @destpadname: (allow-none): the name of the #GstPad in destination element,
- * or NULL for any pad.
+ * or %NULL for any pad.
* @flags: the #GstPadLinkCheck to be performed when linking pads.
*
* Links the two named pads of the source and destination elements.
*
* This is a convenience function for gst_pad_link_full().
*
- * Returns: TRUE if the pads could be linked, FALSE otherwise.
+ * Returns: %TRUE if the pads could be linked, %FALSE otherwise.
*/
gboolean
gst_element_link_pads_full (GstElement * src, const gchar * srcpadname,
GstPad *srcpad, *destpad;
GstPadTemplate *srctempl, *desttempl;
GstElementClass *srcclass, *destclass;
+ gboolean srcrequest, destrequest;
/* checks */
g_return_val_if_fail (GST_IS_ELEMENT (src), FALSE);
srcpadname ? srcpadname : "(any)", GST_ELEMENT_NAME (dest),
destpadname ? destpadname : "(any)");
+ srcrequest = FALSE;
+ destrequest = FALSE;
+
/* get a src pad */
if (srcpadname) {
/* name specified, look it up */
- if (!(srcpad = gst_element_get_static_pad (src, srcpadname)))
- srcpad = gst_element_get_request_pad (src, srcpadname);
+ if (!(srcpad = gst_element_get_static_pad (src, srcpadname))) {
+ if ((srcpad = gst_element_get_request_pad (src, srcpadname)))
+ srcrequest = TRUE;
+ }
if (!srcpad) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s",
GST_ELEMENT_NAME (src), srcpadname);
if (!(GST_PAD_DIRECTION (srcpad) == GST_PAD_SRC)) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no src pad",
GST_DEBUG_PAD_NAME (srcpad));
- gst_object_unref (srcpad);
+ release_and_unref_pad (src, srcpad, srcrequest);
return FALSE;
}
if (GST_PAD_PEER (srcpad) != NULL) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS,
"pad %s:%s is already linked to %s:%s", GST_DEBUG_PAD_NAME (srcpad),
GST_DEBUG_PAD_NAME (GST_PAD_PEER (srcpad)));
+ /* already linked request pads look like static pads, so the request pad
+ * was never requested a second time above, so no need to release it */
gst_object_unref (srcpad);
return FALSE;
}
/* get a destination pad */
if (destpadname) {
/* name specified, look it up */
- if (!(destpad = gst_element_get_static_pad (dest, destpadname)))
- destpad = gst_element_get_request_pad (dest, destpadname);
+ if (!(destpad = gst_element_get_static_pad (dest, destpadname))) {
+ if ((destpad = gst_element_get_request_pad (dest, destpadname)))
+ destrequest = TRUE;
+ }
if (!destpad) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s",
GST_ELEMENT_NAME (dest), destpadname);
+ release_and_unref_pad (src, srcpad, srcrequest);
return FALSE;
} else {
if (!(GST_PAD_DIRECTION (destpad) == GST_PAD_SINK)) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no sink pad",
GST_DEBUG_PAD_NAME (destpad));
- gst_object_unref (destpad);
+ release_and_unref_pad (src, srcpad, srcrequest);
+ release_and_unref_pad (dest, destpad, destrequest);
return FALSE;
}
if (GST_PAD_PEER (destpad) != NULL) {
"pad %s:%s is already linked to %s:%s",
GST_DEBUG_PAD_NAME (destpad),
GST_DEBUG_PAD_NAME (GST_PAD_PEER (destpad)));
+ release_and_unref_pad (src, srcpad, srcrequest);
+ /* already linked request pads look like static pads, so the request pad
+ * was never requested a second time above, so no need to release it */
gst_object_unref (destpad);
return FALSE;
}
/* two explicitly specified pads */
result = pad_link_maybe_ghosting (srcpad, destpad, flags);
- gst_object_unref (srcpad);
- gst_object_unref (destpad);
-
+ if (result) {
+ gst_object_unref (srcpad);
+ gst_object_unref (destpad);
+ } else {
+ release_and_unref_pad (src, srcpad, srcrequest);
+ release_and_unref_pad (dest, destpad, destrequest);
+ }
return result;
}
GST_DEBUG_PAD_NAME (srcpad));
if ((GST_PAD_DIRECTION (srcpad) == GST_PAD_SRC) &&
(GST_PAD_PEER (srcpad) == NULL)) {
+ gboolean temprequest = FALSE;
GstPad *temp;
if (destpadname) {
gst_object_ref (temp);
} else {
temp = gst_element_get_compatible_pad (dest, srcpad, NULL);
+ if (temp && GST_PAD_PAD_TEMPLATE (temp)
+ && GST_PAD_TEMPLATE_PRESENCE (GST_PAD_PAD_TEMPLATE (temp)) ==
+ GST_PAD_REQUEST) {
+ temprequest = TRUE;
+ }
}
if (temp && pad_link_maybe_ghosting (srcpad, temp, flags)) {
}
if (temp) {
+ if (temprequest)
+ gst_element_release_request_pad (dest, temp);
gst_object_unref (temp);
}
}
if (srcpadname) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s:%s to %s",
GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (dest));
+ /* no need to release any request pad as both src- and destpadname must be
+ * set to end up here, but this case has already been taken care of above */
if (destpad)
gst_object_unref (destpad);
destpad = NULL;
}
- if (srcpad)
- gst_object_unref (srcpad);
- srcpad = NULL;
+ if (srcpad) {
+ release_and_unref_pad (src, srcpad, srcrequest);
+ srcpad = NULL;
+ }
if (destpad) {
/* loop through the existing pads in the destination */
if ((GST_PAD_DIRECTION (destpad) == GST_PAD_SINK) &&
(GST_PAD_PEER (destpad) == NULL)) {
GstPad *temp = gst_element_get_compatible_pad (src, destpad, NULL);
+ gboolean temprequest = FALSE;
+
+ if (temp && GST_PAD_PAD_TEMPLATE (temp)
+ && GST_PAD_TEMPLATE_PRESENCE (GST_PAD_PAD_TEMPLATE (temp)) ==
+ GST_PAD_REQUEST) {
+ temprequest = TRUE;
+ }
if (temp && pad_link_maybe_ghosting (temp, destpad, flags)) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s",
gst_object_unref (destpad);
return TRUE;
}
- if (temp) {
- gst_object_unref (temp);
- }
+
+ release_and_unref_pad (src, temp, temprequest);
}
if (destpads) {
destpads = g_list_next (destpads);
if (destpadname) {
GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s:%s",
GST_ELEMENT_NAME (src), GST_DEBUG_PAD_NAME (destpad));
- gst_object_unref (destpad);
+ release_and_unref_pad (dest, destpad, destrequest);
return FALSE;
} else {
- if (destpad)
+ /* no need to release any request pad as the case of unset destpatname and
+ * destpad being a requst pad has already been taken care of when looking
+ * though the destination pads above */
+ if (destpad) {
gst_object_unref (destpad);
+ }
destpad = NULL;
}
return TRUE;
}
/* it failed, so we release the request pads */
- if (srcpad)
+ if (srcpad) {
gst_element_release_request_pad (src, srcpad);
- if (destpad)
+ gst_object_unref (srcpad);
+ }
+ if (destpad) {
gst_element_release_request_pad (dest, destpad);
+ gst_object_unref (destpad);
+ }
}
gst_caps_unref (srccaps);
gst_caps_unref (destcaps);
* gst_element_link_pads:
* @src: a #GstElement containing the source pad.
* @srcpadname: (allow-none): the name of the #GstPad in source element
- * or NULL for any pad.
+ * or %NULL for any pad.
* @dest: (transfer none): the #GstElement containing the destination pad.
* @destpadname: (allow-none): the name of the #GstPad in destination element,
- * or NULL for any pad.
+ * or %NULL for any pad.
*
* Links the two named pads of the source and destination elements.
* Side effect is that if one of the pads has no parent, it becomes a
* child of the parent of the other element. If they have different
* parents, the link fails.
*
- * Returns: TRUE if the pads could be linked, FALSE otherwise.
+ * Returns: %TRUE if the pads could be linked, %FALSE otherwise.
*/
gboolean
gst_element_link_pads (GstElement * src, const gchar * srcpadname,
* gst_element_link_pads_filtered:
* @src: a #GstElement containing the source pad.
* @srcpadname: (allow-none): the name of the #GstPad in source element
- * or NULL for any pad.
+ * or %NULL for any pad.
* @dest: (transfer none): the #GstElement containing the destination pad.
* @destpadname: (allow-none): the name of the #GstPad in destination element
- * or NULL for any pad.
+ * or %NULL for any pad.
* @filter: (transfer none) (allow-none): the #GstCaps to filter the link,
- * or #NULL for no filter.
+ * or %NULL for no filter.
*
* Links the two named pads of the source and destination elements. Side effect
* is that if one of the pads has no parent, it becomes a child of the parent of
* the other element. If they have different parents, the link fails. If @caps
- * is not #NULL, makes sure that the caps of the link is a subset of @caps.
+ * is not %NULL, makes sure that the caps of the link is a subset of @caps.
*
- * Returns: TRUE if the pads could be linked, FALSE otherwise.
+ * Returns: %TRUE if the pads could be linked, %FALSE otherwise.
*/
gboolean
gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
* Make sure you have added your elements to a bin or pipeline with
* gst_bin_add() before trying to link them.
*
- * Returns: TRUE if the elements could be linked, FALSE otherwise.
+ * Returns: %TRUE if the elements could be linked, %FALSE otherwise.
*/
gboolean
gst_element_link (GstElement * src, GstElement * dest)
* gst_element_link_many:
* @element_1: (transfer none): the first #GstElement in the link chain.
* @element_2: (transfer none): the second #GstElement in the link chain.
- * @...: the NULL-terminated list of elements to link in order.
+ * @...: the %NULL-terminated list of elements to link in order.
*
* Chain together a series of elements. Uses gst_element_link().
* Make sure you have added your elements to a bin or pipeline with
* gst_bin_add() before trying to link them.
*
- * Returns: TRUE on success, FALSE otherwise.
+ * Returns: %TRUE on success, %FALSE otherwise.
*/
gboolean
gst_element_link_many (GstElement * element_1, GstElement * element_2, ...)
* @src: a #GstElement containing the source pad.
* @dest: (transfer none): the #GstElement containing the destination pad.
* @filter: (transfer none) (allow-none): the #GstCaps to filter the link,
- * or #NULL for no filter.
+ * or %NULL for no filter.
*
* Links @src to @dest using the given caps as filtercaps.
* The link must be from source to
* Make sure you have added your elements to a bin or pipeline with
* gst_bin_add() before trying to link them.
*
- * Returns: TRUE if the pads could be linked, FALSE otherwise.
+ * Returns: %TRUE if the pads could be linked, %FALSE otherwise.
*/
gboolean
gst_element_link_filtered (GstElement * src, GstElement * dest,
* gst_element_unlink_many:
* @element_1: (transfer none): the first #GstElement in the link chain.
* @element_2: (transfer none): the second #GstElement in the link chain.
- * @...: the NULL-terminated list of elements to unlink in order.
+ * @...: the %NULL-terminated list of elements to unlink in order.
*
* Unlinks a series of elements. Uses gst_element_unlink().
*/
* @element: a #GstElement to invoke the position query on.
* @format: the #GstFormat requested
* @cur: (out) (allow-none): a location in which to store the current
- * position, or NULL.
+ * position, or %NULL.
*
* Queries an element (usually top-level pipeline or playbin element) for the
* stream position in nanoseconds. This will be a value between 0 and the
* If one repeatedly calls this function one can also create a query and reuse
* it in gst_element_query().
*
- * Returns: TRUE if the query could be performed.
+ * Returns: %TRUE if the query could be performed.
*/
gboolean
gst_element_query_position (GstElement * element, GstFormat format,
* gst_element_query_duration:
* @element: a #GstElement to invoke the duration query on.
* @format: the #GstFormat requested
- * @duration: (out) (allow-none): A location in which to store the total duration, or NULL.
+ * @duration: (out) (allow-none): A location in which to store the total duration, or %NULL.
*
* Queries an element (usually top-level pipeline or playbin element) for the
* total stream duration in nanoseconds. This query will only work once the
* message on the pipeline bus, in which case you should re-query the duration
* using this function.
*
- * Returns: TRUE if the query could be performed.
+ * Returns: %TRUE if the query could be performed.
*/
gboolean
gst_element_query_duration (GstElement * element, GstFormat format,
*
* Queries an element to convert @src_val in @src_format to @dest_format.
*
- * Returns: TRUE if the query could be performed.
+ * Returns: %TRUE if the query could be performed.
*/
gboolean
gst_element_query_convert (GstElement * element, GstFormat src_format,
* @pad: a pad
*
* Gets the parent of @pad, cast to a #GstElement. If a @pad has no parent or
- * its parent is not an element, return NULL.
+ * its parent is not an element, return %NULL.
*
- * Returns: (transfer full): the parent of the pad. The caller has a
- * reference on the parent, so unref when you're finished with it.
+ * Returns: (transfer full) (nullable): the parent of the pad. The
+ * caller has a reference on the parent, so unref when you're finished
+ * with it.
*
* MT safe.
*/
* gst_object_default_error:
* @source: the #GstObject that initiated the error.
* @error: (in): the GError.
- * @debug: (in) (allow-none): an additional debug information string, or NULL
+ * @debug: (in) (allow-none): an additional debug information string, or %NULL
*
* A default error function that uses g_printerr() to display the error message
* and the optional debug sting..
* @element_1: (transfer full): the #GstElement element to add to the bin
* @...: (transfer full): additional elements to add to the bin
*
- * Adds a NULL-terminated list of elements to a bin. This function is
+ * Adds a %NULL-terminated list of elements to a bin. This function is
* equivalent to calling gst_bin_add() for each member of the list. The return
* value of each gst_bin_add() is ignored.
*/
* gst_bin_remove_many:
* @bin: a #GstBin
* @element_1: (transfer none): the first #GstElement to remove from the bin
- * @...: (transfer none): NULL-terminated list of elements to remove from the bin
+ * @...: (transfer none): %NULL-terminated list of elements to remove from the bin
*
* Remove a list of elements from a bin. This function is equivalent
* to calling gst_bin_remove() with each member of the list.
* @pad: a #GstPad to proxy.
* @query: an ACCEPT_CAPS #GstQuery.
*
- * Calls gst_pad_accept_caps() for all internally linked pads of @pad and
+ * Checks if all internally linked pads of @pad accepts the caps in @query and
* returns the intersection of the results.
*
* This function is useful as a default accept caps query function for an element
* that can handle any stream format, but requires caps that are acceptable for
- * all oposite pads.
+ * all opposite pads.
*
- * Returns: TRUE if @query could be executed
+ * Returns: %TRUE if @query could be executed
*/
gboolean
gst_pad_proxy_query_accept_caps (GstPad * pad, GstQuery * query)
data.query = query;
/* value to hold the return, by default it holds TRUE */
+ /* FIXME: TRUE is wrong when there are no pads */
data.ret = TRUE;
gst_pad_forward (pad, (GstPadForwardFunction) query_accept_caps_func, &data);
gst_query_set_accept_caps_result (query, data.ret);
- return TRUE;
+ GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "proxying accept caps query: %d",
+ data.ret);
+
+ return data.ret;
}
typedef struct
* @pad: a #GstPad to proxy.
* @query: a CAPS #GstQuery.
*
- * Calls gst_pad_query_caps() for all internally linked pads fof @pad and returns
+ * Calls gst_pad_query_caps() for all internally linked pads of @pad and returns
* the intersection of the results.
*
* This function is useful as a default caps query function for an element
* that can handle any stream format, but requires all its pads to have
* the same caps. Two such elements are tee and adder.
*
- * Returns: TRUE if @query could be executed
+ * Returns: %TRUE if @query could be executed
*/
gboolean
gst_pad_proxy_query_caps (GstPad * pad, GstQuery * query)
gst_query_set_caps_result (query, result);
gst_caps_unref (result);
+ /* FIXME: return something depending on the processing */
return TRUE;
}
* gst_pad_query_position:
* @pad: a #GstPad to invoke the position query on.
* @format: the #GstFormat requested
- * @cur: (out) (allow-none): A location in which to store the current position, or NULL.
+ * @cur: (out) (allow-none): A location in which to store the current position, or %NULL.
*
* Queries a pad for the stream position.
*
- * Returns: TRUE if the query could be performed.
+ * Returns: %TRUE if the query could be performed.
*/
gboolean
gst_pad_query_position (GstPad * pad, GstFormat format, gint64 * cur)
* Must be a sink pad.
* @format: the #GstFormat requested
* @cur: (out) (allow-none): a location in which to store the current
- * position, or NULL.
+ * position, or %NULL.
*
* Queries the peer of a given sink pad for the stream position.
*
- * Returns: TRUE if the query could be performed.
+ * Returns: %TRUE if the query could be performed.
*/
gboolean
gst_pad_peer_query_position (GstPad * pad, GstFormat format, gint64 * cur)
gboolean ret = FALSE;
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
- g_return_val_if_fail (GST_PAD_IS_SINK (pad), FALSE);
g_return_val_if_fail (format != GST_FORMAT_UNDEFINED, FALSE);
query = gst_query_new_position (format);
* @pad: a #GstPad to invoke the duration query on.
* @format: the #GstFormat requested
* @duration: (out) (allow-none): a location in which to store the total
- * duration, or NULL.
+ * duration, or %NULL.
*
* Queries a pad for the total stream duration.
*
- * Returns: TRUE if the query could be performed.
+ * Returns: %TRUE if the query could be performed.
*/
gboolean
gst_pad_query_duration (GstPad * pad, GstFormat format, gint64 * duration)
* Must be a sink pad.
* @format: the #GstFormat requested
* @duration: (out) (allow-none): a location in which to store the total
- * duration, or NULL.
+ * duration, or %NULL.
*
* Queries the peer pad of a given sink pad for the total stream duration.
*
- * Returns: TRUE if the query could be performed.
+ * Returns: %TRUE if the query could be performed.
*/
gboolean
gst_pad_peer_query_duration (GstPad * pad, GstFormat format, gint64 * duration)
*
* Queries a pad to convert @src_val in @src_format to @dest_format.
*
- * Returns: TRUE if the query could be performed.
+ * Returns: %TRUE if the query could be performed.
*/
gboolean
gst_pad_query_convert (GstPad * pad, GstFormat src_format, gint64 src_val,
* Queries the peer pad of a given sink pad to convert @src_val in @src_format
* to @dest_format.
*
- * Returns: TRUE if the query could be performed.
+ * Returns: %TRUE if the query could be performed.
*/
gboolean
gst_pad_peer_query_convert (GstPad * pad, GstFormat src_format, gint64 src_val,
/**
* gst_pad_query_caps:
* @pad: a #GstPad to get the capabilities of.
- * @filter: (allow-none): suggested #GstCaps, or NULL
+ * @filter: (allow-none): suggested #GstCaps, or %NULL
*
* Gets the capabilities this pad can produce or consume.
* Note that this method doesn't necessarily return the caps set by sending a
* gst_event_new_caps() - use gst_pad_get_current_caps() for that instead.
* gst_pad_query_caps returns all possible caps a pad can operate with, using
* the pad's CAPS query function, If the query fails, this function will return
- * @filter, if not #NULL, otherwise ANY.
+ * @filter, if not %NULL, otherwise ANY.
*
* When called on sinkpads @filter contains the caps that
* upstream could produce in the order preferred by upstream. When
* called on srcpads @filter contains the caps accepted by
- * downstream in the preffered order. @filter might be %NULL but
+ * downstream in the preferred order. @filter might be %NULL but
* if it is not %NULL the returned caps will be a subset of @filter.
*
* Note that this function does not return writable #GstCaps, use
/**
* gst_pad_peer_query_caps:
* @pad: a #GstPad to get the capabilities of.
- * @filter: (allow-none): a #GstCaps filter, or NULL.
+ * @filter: (allow-none): a #GstCaps filter, or %NULL.
*
* Gets the capabilities of the peer connected to this pad. Similar to
* gst_pad_query_caps().
* When called on srcpads @filter contains the caps that
* upstream could produce in the order preferred by upstream. When
* called on sinkpads @filter contains the caps accepted by
- * downstream in the preffered order. @filter might be %NULL but
+ * downstream in the preferred order. @filter might be %NULL but
* if it is not %NULL the returned caps will be a subset of @filter.
*
* Returns: the caps of the peer pad with incremented ref-count. When there is
*
* Check if the given pad accepts the caps.
*
- * Returns: TRUE if the pad can accept the caps.
+ * Returns: %TRUE if the pad can accept the caps.
*/
gboolean
gst_pad_query_accept_caps (GstPad * pad, GstCaps * caps)
* @caps: a #GstCaps to check on the pad
*
* Check if the peer of @pad accepts @caps. If @pad has no peer, this function
- * returns TRUE.
+ * returns %TRUE.
*
- * Returns: TRUE if the peer of @pad can accept the caps or @pad has no peer.
+ * Returns: %TRUE if the peer of @pad can accept the caps or @pad has no peer.
*/
gboolean
gst_pad_peer_query_accept_caps (GstPad * pad, GstCaps * caps)
*
* Recursively looks for elements with an unlinked pad of the given
* direction within the specified bin and returns an unlinked pad
- * if one is found, or NULL otherwise. If a pad is found, the caller
+ * if one is found, or %NULL otherwise. If a pad is found, the caller
* owns a reference to it and should use gst_object_unref() on the
* pad when it is not needed any longer.
*
- * Returns: (transfer full): unlinked pad of the given direction, or NULL.
+ * Returns: (transfer full) (nullable): unlinked pad of the given
+ * direction, %NULL.
*/
GstPad *
gst_bin_find_unlinked_pad (GstBin * bin, GstPadDirection direction)
return pad;
}
+static void
+gst_bin_sync_children_states_foreach (const GValue * value, gpointer user_data)
+{
+ gboolean *success = user_data;
+ GstElement *element = g_value_get_object (value);
+
+ if (gst_element_is_locked_state (element)) {
+ *success = TRUE;
+ } else {
+ *success = *success && gst_element_sync_state_with_parent (element);
+
+ if (GST_IS_BIN (element))
+ *success = *success
+ && gst_bin_sync_children_states (GST_BIN_CAST (element));
+ }
+}
+
+/**
+ * gst_bin_sync_children_states:
+ * @bin: a #GstBin
+ *
+ * Synchronizes the state of every child of @bin with the state
+ * of @bin. See also gst_element_sync_state_with_parent().
+ *
+ * Returns: %TRUE if syncing the state was successful for all children,
+ * otherwise %FALSE.
+ *
+ * Since: 1.6
+ */
+gboolean
+gst_bin_sync_children_states (GstBin * bin)
+{
+ GstIterator *it;
+ GstIteratorResult res = GST_ITERATOR_OK;
+ gboolean success = TRUE;
+
+ it = gst_bin_iterate_sorted (bin);
+
+ do {
+ if (res == GST_ITERATOR_RESYNC) {
+ success = TRUE;
+ gst_iterator_resync (it);
+ }
+ res =
+ gst_iterator_foreach (it, gst_bin_sync_children_states_foreach,
+ &success);
+ } while (res == GST_ITERATOR_RESYNC);
+ gst_iterator_free (it);
+
+ return success;
+}
+
/**
* gst_parse_bin_from_description:
* @bin_description: command line describing the bin
* @ghost_unlinked_pads: whether to automatically create ghost pads
* for unlinked source or sink pads within the bin
- * @err: where to store the error message in case of an error, or NULL
+ * @err: where to store the error message in case of an error, or %NULL
*
* This is a convenience wrapper around gst_parse_launch() to create a
* #GstBin from a gst-launch-style pipeline description. See
* and want them all ghosted, you will have to create the ghost pads
* yourself).
*
- * Returns: (transfer floating) (type Gst.Bin): a newly-created bin,
- * or %NULL if an error occurred.
+ * Returns: (transfer floating) (type Gst.Bin) (nullable): a
+ * newly-created bin, or %NULL if an error occurred.
*/
GstElement *
gst_parse_bin_from_description (const gchar * bin_description,
* @context: (transfer none) (allow-none): a parse context allocated with
* gst_parse_context_new(), or %NULL
* @flags: parsing options, or #GST_PARSE_FLAG_NONE
- * @err: where to store the error message in case of an error, or NULL
+ * @err: where to store the error message in case of an error, or %NULL
*
* This is a convenience wrapper around gst_parse_launch() to create a
* #GstBin from a gst-launch-style pipeline description. See
* and want them all ghosted, you will have to create the ghost pads
* yourself).
*
- * Returns: (transfer full) (type Gst.Element): a newly-created element, which
- * is guaranteed to be a bin unless GST_FLAG_NO_SINGLE_ELEMENT_BINS was
- * passed, or %NULL if an error occurred.
+ * Returns: (transfer floating) (type Gst.Element): a newly-created
+ * element, which is guaranteed to be a bin unless
+ * GST_FLAG_NO_SINGLE_ELEMENT_BINS was passed, or %NULL if an error
+ * occurred.
*/
GstElement *
gst_parse_bin_from_description_full (const gchar * bin_description,
*
* The complexity of this search function is O(log (num_elements)).
*
- * Returns: (transfer none): The address of the found element or %NULL if nothing was found
+ * Returns: (transfer none) (nullable): The address of the found
+ * element or %NULL if nothing was found
*/
gpointer
gst_util_array_binary_search (gpointer array, guint num_elements,
g_return_val_if_fail (a_d != 0, FALSE);
g_return_val_if_fail (b_d != 0, FALSE);
+ /* early out if either is 0, as its gcd would be 0 */
+ if (a_n == 0 || b_n == 0) {
+ *res_n = 0;
+ *res_d = 1;
+ return TRUE;
+ }
+
gcd = gst_util_greatest_common_divisor (a_n, a_d);
a_n /= gcd;
a_d /= gcd;
* here is for source elements */
if (!upstream_stream_id) {
GstQuery *query;
+ gchar *uri = NULL;
/* Try to generate one from the URI query and
* if it fails take a random number instead */
query = gst_query_new_uri ();
if (gst_element_query (parent, query)) {
- GChecksum *cs;
- gchar *uri;
-
gst_query_parse_uri (query, &uri);
+ }
+
+ if (uri) {
+ GChecksum *cs;
/* And then generate an SHA256 sum of the URI */
cs = g_checksum_new (G_CHECKSUM_SHA256);
* The returned stream-id string should be treated as an opaque string, its
* contents should not be interpreted.
*
- * Returns: a newly-allocated copy of the stream-idfor @pad, or %NULL.
- * g_free() the returned string when no longer needed.
+ * Returns: (nullable): a newly-allocated copy of the stream-id for
+ * @pad, or %NULL. g_free() the returned string when no longer
+ * needed.
*
* Since: 1.2
*/