gstpad: Return pad template in get_caps if pad is not negotiable

https://bugzilla.gnome.org/show_bug.cgi?id=618644
This commit is contained in:
Edward Hervey 2010-05-17 15:06:37 +02:00
parent dc38e75d88
commit 7460321a60
2 changed files with 14 additions and 0 deletions

View file

@ -2181,6 +2181,14 @@ gst_pad_get_caps_unlocked (GstPad * pad)
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps"); GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps");
/* If the parent element is in GST_STATE_NULL, return the template caps */
if (G_UNLIKELY (!GST_PAD_IS_NEGOTIABLE (pad) && GST_PAD_PAD_TEMPLATE (pad))) {
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
"parent element is in GST_STATE_NULL, using pad templates");
result = gst_caps_ref (GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (pad)));
goto done;
}
if (GST_PAD_GETCAPSFUNC (pad)) { if (GST_PAD_GETCAPSFUNC (pad)) {
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
"dispatching to pad getcaps function"); "dispatching to pad getcaps function");

View file

@ -591,6 +591,9 @@ GST_START_TEST (test_ghost_pads_new_from_template)
/* check template is properly set */ /* check template is properly set */
fail_unless (GST_PAD_PAD_TEMPLATE (ghostpad) == ghosttempl); fail_unless (GST_PAD_PAD_TEMPLATE (ghostpad) == ghosttempl);
/* Set pad negotiable so the getcaps call goes through */
gst_pad_set_negotiable (ghostpad, TRUE);
/* check ghostpad caps are from the sinkpad */ /* check ghostpad caps are from the sinkpad */
newcaps = gst_pad_get_caps (ghostpad); newcaps = gst_pad_get_caps (ghostpad);
fail_unless (newcaps != NULL); fail_unless (newcaps != NULL);
@ -645,6 +648,9 @@ GST_START_TEST (test_ghost_pads_new_no_target_from_template)
fail_unless (gst_ghost_pad_set_target ((GstGhostPad *) ghostpad, sinkpad)); fail_unless (gst_ghost_pad_set_target ((GstGhostPad *) ghostpad, sinkpad));
/* set pad negotiable so the getcaps call goes through */
gst_pad_set_negotiable (ghostpad, TRUE);
/* check ghostpad caps are now from the target pad */ /* check ghostpad caps are now from the target pad */
newcaps = gst_pad_get_caps (ghostpad); newcaps = gst_pad_get_caps (ghostpad);
fail_unless (newcaps != NULL); fail_unless (newcaps != NULL);