-/**
- * gst_proxy_pad_getcaps_default:
- * @pad: a #GstPad to get the capabilities of.
- * @filter: a #GstCaps filter.
- *
- * Invoke the default getcaps function of the proxy pad.
- *
- * Returns: (transfer full): the caps of the pad with incremented ref-count
- *
- * Since: 0.10.35
- */
-GstCaps *
-gst_proxy_pad_getcaps_default (GstPad * pad, GstCaps * filter)
-{
- GstPad *target;
- GstCaps *res;
- GstPadTemplate *templ;
-
- g_return_val_if_fail (GST_IS_PROXY_PAD (pad), NULL);
-
- templ = GST_PAD_PAD_TEMPLATE (pad);
- target = gst_proxy_pad_get_target (pad);
- if (target) {
- /* if we have a real target, proxy the call */
- res = gst_pad_get_caps (target, filter);
-
- GST_DEBUG_OBJECT (pad, "get caps of target %s:%s : %" GST_PTR_FORMAT,
- GST_DEBUG_PAD_NAME (target), res);
-
- gst_object_unref (target);
-
- /* filter against the template */
- if (templ && res) {
- GstCaps *filt, *tmp;
-
- filt = GST_PAD_TEMPLATE_CAPS (templ);
- if (filt) {
- tmp = gst_caps_intersect_full (res, filt, GST_CAPS_INTERSECT_FIRST);
- gst_caps_unref (res);
- res = tmp;
- GST_DEBUG_OBJECT (pad,
- "filtered against template gives %" GST_PTR_FORMAT, res);
- }
- }
- } else {
- /* else, if we have a template, use its caps. */
- if (templ) {
- res = GST_PAD_TEMPLATE_CAPS (templ);
- GST_DEBUG_OBJECT (pad,
- "using pad template %p with caps %p %" GST_PTR_FORMAT, templ, res,
- res);
- res = gst_caps_ref (res);
-
- if (filter) {
- GstCaps *intersection =
- gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
-
- gst_caps_unref (res);
- res = intersection;
- }
-
- goto done;
- }
-
- /* last resort, any caps */
- GST_DEBUG_OBJECT (pad, "pad has no template, returning ANY");
- res = gst_caps_new_any ();
- }
-
-done:
- return res;
-}
-
-/**
- * gst_proxy_pad_acceptcaps_default:
- * @pad: a #GstPad to check
- * @caps: a #GstCaps to check on the pad
- *
- * Invoke the default acceptcaps function of the proxy pad.
- *
- * Returns: TRUE if the pad can accept the caps.
- *
- * Since: 0.10.35
- */
-gboolean
-gst_proxy_pad_acceptcaps_default (GstPad * pad, GstCaps * caps)
-{
- GstPad *target;
- gboolean res;
-
- g_return_val_if_fail (GST_IS_PROXY_PAD (pad), FALSE);
- g_return_val_if_fail (caps == NULL || GST_IS_CAPS (caps), FALSE);
-
- target = gst_proxy_pad_get_target (pad);
- if (target) {
- res = gst_pad_accept_caps (target, caps);
- gst_object_unref (target);
- } else {
- GST_DEBUG_OBJECT (pad, "no target");
- /* We don't have a target, we return TRUE and we assume that any future
- * target will be able to deal with any configured caps. */
- res = TRUE;
- }
-
- return res;
-}
-
-/**
- * gst_proxy_pad_fixatecaps_default:
- * @pad: a #GstPad to fixate
- * @caps: the #GstCaps to fixate
- *
- * Invoke the default fixatecaps function of the proxy pad.
- *
- * Since: 0.10.35
- */
-void
-gst_proxy_pad_fixatecaps_default (GstPad * pad, GstCaps * caps)
-{
- GstPad *target;
-
- g_return_if_fail (GST_IS_PROXY_PAD (pad));
- g_return_if_fail (GST_IS_CAPS (caps));
-
- if (!(target = gst_proxy_pad_get_target (pad)))
- goto no_target;
-
- gst_pad_fixate_caps (target, caps);
- gst_object_unref (target);
-
- return;
-
- /* ERRORS */
-no_target:
- {
- GST_DEBUG_OBJECT (pad, "no target");
- return;
- }
-}
-
-static gboolean
-gst_proxy_pad_set_target_unlocked (GstPad * pad, GstPad * target)
-{
- GstPad *oldtarget;
-
- if (target) {
- GST_LOG_OBJECT (pad, "setting target %s:%s", GST_DEBUG_PAD_NAME (target));
-
- if (G_UNLIKELY (GST_PAD_DIRECTION (pad) != GST_PAD_DIRECTION (target)))
- goto wrong_direction;
- } else
- GST_LOG_OBJECT (pad, "clearing target");
-
- /* clear old target */
- if ((oldtarget = GST_PROXY_PAD_TARGET (pad)))
- gst_object_unref (oldtarget);
-
- /* set and ref new target if any */
- if (target)
- GST_PROXY_PAD_TARGET (pad) = gst_object_ref (target);
- else
- GST_PROXY_PAD_TARGET (pad) = NULL;
-
- return TRUE;
-
- /* ERRORS */
-wrong_direction:
- {
- GST_ERROR_OBJECT (pad,
- "target pad doesn't have the same direction as ourself");
- return FALSE;
- }
-}
-
-static gboolean
-gst_proxy_pad_set_target (GstPad * pad, GstPad * target)
-{
- gboolean result;
-
- GST_PROXY_LOCK (pad);
- result = gst_proxy_pad_set_target_unlocked (pad, target);
- GST_PROXY_UNLOCK (pad);
-
- return result;
-}
-