}
}
-typedef struct
-{
- GstPad *orig;
- GstCaps *caps;
-} SetCapsFoldData;
-
-static gboolean
-setcaps_fold_func (const GValue * vpad, GValue * ret, SetCapsFoldData * data)
-{
- gboolean success = TRUE;
- GstPad *pad = g_value_get_object (vpad);
-
- if (pad != data->orig) {
- success = gst_pad_set_caps (pad, data->caps);
- g_value_set_boolean (ret, success);
- }
-
- return success;
-}
-
-/**
- * gst_pad_proxy_setcaps
- * @pad: a #GstPad to proxy from
- * @caps: (transfer none): the #GstCaps to link with
- *
- * Calls gst_pad_set_caps() for every other pad belonging to the
- * same element as @pad. If gst_pad_set_caps() fails on any pad,
- * the proxy setcaps fails. May be used only during negotiation.
- *
- * Returns: TRUE if sucessful
- */
-gboolean
-gst_pad_proxy_setcaps (GstPad * pad, GstCaps * caps)
-{
- GstElement *element;
- GstIterator *iter;
- GstIteratorResult res;
- GValue ret = { 0, };
- SetCapsFoldData data;
-
- g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
- g_return_val_if_fail (caps != NULL, FALSE);
-
- GST_CAT_DEBUG (GST_CAT_PADS, "proxying pad link for %s:%s",
- GST_DEBUG_PAD_NAME (pad));
-
- element = gst_pad_get_parent_element (pad);
- if (element == NULL)
- return FALSE;
-
- /* only iterate the pads in the oposite direction */
- if (GST_PAD_IS_SRC (pad))
- iter = gst_element_iterate_sink_pads (element);
- else
- iter = gst_element_iterate_src_pads (element);
-
- g_value_init (&ret, G_TYPE_BOOLEAN);
- g_value_set_boolean (&ret, TRUE);
- data.orig = pad;
- data.caps = caps;
-
- while (1) {
- res = gst_iterator_fold (iter, (GstIteratorFoldFunction) setcaps_fold_func,
- &ret, &data);
-
- switch (res) {
- case GST_ITERATOR_RESYNC:
- /* reset return value */
- g_value_set_boolean (&ret, TRUE);
- gst_iterator_resync (iter);
- break;
- case GST_ITERATOR_DONE:
- /* all pads iterated, return collected value */
- goto done;
- default:
- /* iterator returned _ERROR or premature end with _OK,
- * mark an error and exit */
- goto error;
- }
- }
-done:
- gst_iterator_free (iter);
-
- gst_object_unref (element);
-
- /* ok not to unset the gvalue */
- return g_value_get_boolean (&ret);
-
- /* ERRORS */
-error:
- {
- g_warning ("Pad list return error on element %s",
- GST_ELEMENT_NAME (element));
- gst_iterator_free (iter);
- gst_object_unref (element);
- return FALSE;
- }
-}
-
/**
* gst_pad_query_position:
* @pad: a #GstPad to invoke the position query on.