From 160dce872b48641cc5834a923be1336cd98153e8 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Tue, 16 Dec 2014 18:36:57 -0300 Subject: [PATCH] audiodecoder: implement caps and accept-caps queries Allows decoders to proxy downstream restrictions on caps. Also implements accept-caps query to prevent regressions caused by the new fields on the return of a caps query that would cause the accept-caps to fail as it uses subset caps comparisons --- gst-libs/gst/audio/gstaudiodecoder.c | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c index a5d10ad274..efd979b9ca 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.c +++ b/gst-libs/gst/audio/gstaudiodecoder.c @@ -149,6 +149,7 @@ #endif #include "gstaudiodecoder.h" +#include "gstaudioutilsprivate.h" #include #include @@ -2460,6 +2461,44 @@ gst_audio_decoder_sink_query (GstPad * pad, GstObject * parent, res = klass->propose_allocation (dec, query); break; } + case GST_QUERY_CAPS:{ + GstCaps *filter; + GstCaps *result; + + gst_query_parse_caps (query, &filter); + result = __gst_audio_element_proxy_getcaps (GST_ELEMENT_CAST (dec), + GST_AUDIO_DECODER_SINK_PAD (dec), + GST_AUDIO_DECODER_SRC_PAD (dec), NULL, filter); + gst_query_set_caps_result (query, result); + gst_caps_unref (result); + res = TRUE; + break; + } + case GST_QUERY_ACCEPT_CAPS:{ + GstCaps *caps; + GstCaps *allowed_caps; + GstCaps *template_caps; + gboolean accept; + + gst_query_parse_accept_caps (query, &caps); + + template_caps = gst_pad_get_pad_template_caps (pad); + accept = gst_caps_is_subset (caps, template_caps); + gst_caps_unref (template_caps); + + if (accept) { + allowed_caps = gst_pad_query_caps (GST_AUDIO_DECODER_SINK_PAD (dec), + caps); + + accept = gst_caps_can_intersect (caps, allowed_caps); + + gst_caps_unref (allowed_caps); + } + + gst_query_set_accept_caps_result (query, accept); + res = TRUE; + break; + } case GST_QUERY_SEEKING: { GstFormat format;