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
This commit is contained in:
Thiago Santos 2014-12-16 18:36:57 -03:00
parent 5e3405bd08
commit 160dce872b

View file

@ -149,6 +149,7 @@
#endif
#include "gstaudiodecoder.h"
#include "gstaudioutilsprivate.h"
#include <gst/pbutils/descriptions.h>
#include <string.h>
@ -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;