vtdec: try to preserve downstream caps order

vtdec specifies sysmem; GLMemory as template caps. When negotiating, we used to
call gst_pad_peer_query_caps (..., filter) with our template caps as filter. The
query does gst_caps_intersect (filter, peercaps) internally which gives
precedence to the order of the filter caps. While we want to output sysmem by
default, when negotiating with glimagesink which returns GLMemory; sysmem; we
do want to do GL, so we now query using a NULL filter and intersect the result
with our template caps giving precedence to downstream's caps.

tl;dr: make sure we end up negotiating GLMemory with glimagesink
This commit is contained in:
Alessandro Decina 2016-06-07 16:00:01 +10:00
parent 26b66a1db5
commit 7fea17a476

View file

@ -220,7 +220,7 @@ static gboolean
gst_vtdec_negotiate (GstVideoDecoder * decoder) gst_vtdec_negotiate (GstVideoDecoder * decoder)
{ {
GstVideoCodecState *output_state = NULL; GstVideoCodecState *output_state = NULL;
GstCaps *caps = NULL, *templcaps = NULL, *prevcaps = NULL; GstCaps *peercaps = NULL, *caps = NULL, *templcaps = NULL, *prevcaps = NULL;
GstVideoFormat format; GstVideoFormat format;
GstStructure *structure; GstStructure *structure;
const gchar *s; const gchar *s;
@ -232,12 +232,13 @@ gst_vtdec_negotiate (GstVideoDecoder * decoder)
vtdec = GST_VTDEC (decoder); vtdec = GST_VTDEC (decoder);
templcaps = templcaps =
gst_pad_get_pad_template_caps (GST_VIDEO_DECODER_SRC_PAD (decoder)); gst_pad_get_pad_template_caps (GST_VIDEO_DECODER_SRC_PAD (decoder));
peercaps = gst_pad_peer_query_caps (GST_VIDEO_DECODER_SRC_PAD (vtdec), NULL);
caps = caps =
gst_caps_make_writable (gst_pad_peer_query_caps (GST_VIDEO_DECODER_SRC_PAD gst_caps_intersect_full (peercaps, templcaps, GST_CAPS_INTERSECT_FIRST);
(vtdec), templcaps));
gst_caps_unref (templcaps); gst_caps_unref (templcaps);
gst_caps_unref (peercaps);
caps = gst_caps_truncate (caps); caps = gst_caps_truncate (gst_caps_make_writable (caps));
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
s = gst_structure_get_string (structure, "format"); s = gst_structure_get_string (structure, "format");
format = gst_video_format_from_string (s); format = gst_video_format_from_string (s);