From 9ac74f62267e65c58a11e7f923b9659bc9f67c49 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Fri, 24 Oct 2014 00:35:22 +1100 Subject: [PATCH] glmixer: override the caps query in order to 'convert' capsfeatures Otherwise, it is only possible for the sink pads and the src pads to have the exact same caps features. We can convert from any feature to another feature so support that. --- ext/gl/gstglmixer.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/ext/gl/gstglmixer.c b/ext/gl/gstglmixer.c index da6ba67ed0..a80d2b726c 100644 --- a/ext/gl/gstglmixer.c +++ b/ext/gl/gstglmixer.c @@ -287,6 +287,37 @@ gst_gl_mixer_pad_sink_acceptcaps (GstPad * pad, GstGLMixer * mix, return ret; } +static GstCaps * +gst_gl_mixer_pad_sink_getcaps (GstPad * pad, GstGLMixer * mix, GstCaps * filter) +{ + GstCaps *srccaps; + GstCaps *template_caps; + GstCaps *filtered_caps; + GstCaps *returned_caps; + gboolean had_current_caps = TRUE; + + template_caps = gst_pad_get_pad_template_caps (pad); + + srccaps = gst_pad_get_current_caps (pad); + if (srccaps == NULL) { + had_current_caps = FALSE; + srccaps = template_caps; + } + + filtered_caps = srccaps; + if (filter) + filtered_caps = gst_caps_intersect (srccaps, filter); + returned_caps = gst_caps_intersect (filtered_caps, template_caps); + + gst_caps_unref (srccaps); + if (filter) + gst_caps_unref (filtered_caps); + if (had_current_caps) + gst_caps_unref (template_caps); + + return returned_caps; +} + static gboolean gst_gl_mixer_sink_query (GstAggregator * agg, GstAggregatorPad * bpad, GstQuery * query) @@ -297,6 +328,17 @@ gst_gl_mixer_sink_query (GstAggregator * agg, GstAggregatorPad * bpad, GST_TRACE ("QUERY %" GST_PTR_FORMAT, query); switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_CAPS: + { + GstCaps *filter, *caps; + + gst_query_parse_caps (query, &filter); + caps = gst_gl_mixer_pad_sink_getcaps (GST_PAD (bpad), mix, filter); + gst_query_set_caps_result (query, caps); + gst_caps_unref (caps); + ret = TRUE; + break; + } case GST_QUERY_ACCEPT_CAPS: { GstCaps *caps;