From fabc5c969be34e496662a810ba1b3f0b2721163d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 24 Nov 2011 09:48:33 +0100 Subject: [PATCH] ac3parse: Implement ::get_sink_caps vfunc to propagate downstream caps constraints upstream --- gst/audioparsers/gstac3parse.c | 38 +++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/gst/audioparsers/gstac3parse.c b/gst/audioparsers/gstac3parse.c index f907249076..d7354eb1df 100644 --- a/gst/audioparsers/gstac3parse.c +++ b/gst/audioparsers/gstac3parse.c @@ -165,6 +165,7 @@ static GstFlowReturn gst_ac3_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame); static gboolean gst_ac3_parse_src_event (GstBaseParse * parse, GstEvent * event); +static GstCaps *gst_ac3_parse_get_sink_caps (GstBaseParse * parse); GST_BOILERPLATE (GstAc3Parse, gst_ac3_parse, GstBaseParse, GST_TYPE_BASE_PARSE); @@ -199,8 +200,8 @@ gst_ac3_parse_class_init (GstAc3ParseClass * klass) parse_class->check_valid_frame = GST_DEBUG_FUNCPTR (gst_ac3_parse_check_valid_frame); parse_class->parse_frame = GST_DEBUG_FUNCPTR (gst_ac3_parse_parse_frame); - parse_class->src_event = GST_DEBUG_FUNCPTR (gst_ac3_parse_src_event); + parse_class->get_sink_caps = GST_DEBUG_FUNCPTR (gst_ac3_parse_get_sink_caps); } static void @@ -662,3 +663,38 @@ gst_ac3_parse_src_event (GstBaseParse * parse, GstEvent * event) return GST_BASE_PARSE_CLASS (parent_class)->src_event (parse, event); } + +static GstCaps * +gst_ac3_parse_get_sink_caps (GstBaseParse * parse) +{ + GstCaps *peercaps; + GstCaps *res; + + peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (peercaps) { + guint i, n; + + /* Remove the framed and alignment field. We can convert + * between different alignments. */ + peercaps = gst_caps_make_writable (peercaps); + n = gst_caps_get_size (peercaps); + for (i = 0; i < n; i++) { + GstStructure *s = gst_caps_get_structure (peercaps, i); + + gst_structure_remove_field (s, "framed"); + gst_structure_remove_field (s, "alignment"); + } + + res = + gst_caps_intersect_full (peercaps, + gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)), + GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (peercaps); + } else { + res = + gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD + (parse))); + } + + return res; +}