From 76d26a60bd761780bdb4865ab6a5950323086e01 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Fri, 28 Aug 2015 09:36:15 -0300 Subject: [PATCH] playsinkconvertbin: implement accept-caps handler The default one will just go through the internal elements which might just be identity when it is in passthrough which will lead to the query being handled by the downstream sink, ignoring all that playsinkconvertbin could actually handle and convert. https://bugzilla.gnome.org/show_bug.cgi?id=754235 --- gst/playback/gstplaysinkconvertbin.c | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/gst/playback/gstplaysinkconvertbin.c b/gst/playback/gstplaysinkconvertbin.c index af2333fce4..0930810249 100644 --- a/gst/playback/gstplaysinkconvertbin.c +++ b/gst/playback/gstplaysinkconvertbin.c @@ -350,6 +350,42 @@ gst_play_sink_convert_bin_sink_setcaps (GstPlaySinkConvertBin * self, } \ } G_STMT_END +static gboolean +gst_play_sink_convert_bin_acceptcaps (GstPad * pad, GstCaps * caps) +{ + GstPlaySinkConvertBin *self = + GST_PLAY_SINK_CONVERT_BIN (gst_pad_get_parent (pad)); + gboolean ret; + GstPad *otherpad; + + GST_PLAY_SINK_CONVERT_BIN_LOCK (self); + if (pad == self->srcpad) { + otherpad = self->sinkpad; + } else if (pad == self->sinkpad) { + otherpad = self->srcpad; + } else { + GST_ERROR_OBJECT (pad, "Not one of our pads"); + otherpad = NULL; + } + + if (otherpad) { + ret = gst_pad_peer_query_accept_caps (otherpad, caps); + if (!ret && self->converter_caps) { + /* maybe we can convert */ + ret = gst_caps_can_intersect (caps, self->converter_caps); + } + } else { + ret = TRUE; + } + GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self); + + gst_object_unref (self); + + GST_DEBUG_OBJECT (pad, "Accept caps: '%" GST_PTR_FORMAT "' %d", caps, ret); + + return ret; +} + static GstCaps * gst_play_sink_convert_bin_getcaps (GstPad * pad, GstCaps * filter) { @@ -474,6 +510,17 @@ gst_play_sink_convert_bin_query (GstPad * pad, GstObject * parent, res = TRUE; break; } + case GST_QUERY_ACCEPT_CAPS: + { + gboolean ret; + GstCaps *caps; + + gst_query_parse_accept_caps (query, &caps); + ret = gst_play_sink_convert_bin_acceptcaps (pad, caps); + gst_query_set_accept_caps_result (query, ret); + res = TRUE; + break; + } default: res = gst_pad_query_default (pad, parent, query); break;