textrender: Correctly negotiate with downstream instead of just using random caps

Fixes bug #638897.
This commit is contained in:
Jindrich Makovicka 2011-05-26 10:48:05 +02:00 committed by Sebastian Dröge
parent c186d400e5
commit 2ba4a56d74

View file

@ -467,7 +467,7 @@ gst_text_render_chain (GstPad * pad, GstBuffer * inbuf)
GstTextRender *render; GstTextRender *render;
GstFlowReturn ret; GstFlowReturn ret;
GstBuffer *outbuf; GstBuffer *outbuf;
GstCaps *caps = NULL; GstCaps *caps = NULL, *padcaps, *peercaps;
guint8 *data = GST_BUFFER_DATA (inbuf); guint8 *data = GST_BUFFER_DATA (inbuf);
guint size = GST_BUFFER_SIZE (inbuf); guint size = GST_BUFFER_SIZE (inbuf);
gint n; gint n;
@ -489,16 +489,21 @@ gst_text_render_chain (GstPad * pad, GstBuffer * inbuf)
gst_text_render_check_argb (render); gst_text_render_check_argb (render);
if (!render->use_ARGB) { peercaps = gst_pad_peer_get_caps (render->srcpad);
caps = padcaps = gst_pad_get_caps (render->srcpad);
gst_video_format_new_caps (GST_VIDEO_FORMAT_AYUV, render->width, caps = gst_caps_intersect (padcaps, peercaps);
render->height, 1, 1, 1, 1); gst_caps_unref (padcaps);
} else { gst_caps_unref (peercaps);
caps =
gst_video_format_new_caps (GST_VIDEO_FORMAT_ARGB, render->width, if (!caps || gst_caps_is_empty (caps)) {
render->height, 1, 1, 1, 1); GST_ELEMENT_ERROR (render, CORE, NEGOTIATION, (NULL), (NULL));
ret = GST_FLOW_ERROR;
goto done;
} }
gst_caps_truncate (caps);
gst_pad_fixate_caps (render->srcpad, caps);
if (!gst_pad_set_caps (render->srcpad, caps)) { if (!gst_pad_set_caps (render->srcpad, caps)) {
GST_ELEMENT_ERROR (render, CORE, NEGOTIATION, (NULL), (NULL)); GST_ELEMENT_ERROR (render, CORE, NEGOTIATION, (NULL), (NULL));
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;