From 996b4eb4ccf90ce94604fe5dc034a4dfd23d9489 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 24 Nov 2011 09:57:57 +0100 Subject: [PATCH] flacparse: Implement ::get_sink_caps vfunc to propagate downstream caps constraints upstream --- gst/audioparsers/gstflacparse.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/gst/audioparsers/gstflacparse.c b/gst/audioparsers/gstflacparse.c index 637319f..36db7c1 100644 --- a/gst/audioparsers/gstflacparse.c +++ b/gst/audioparsers/gstflacparse.c @@ -201,6 +201,7 @@ static GstFlowReturn gst_flac_parse_pre_push_frame (GstBaseParse * parse, static gboolean gst_flac_parse_convert (GstBaseParse * parse, GstFormat src_format, gint64 src_value, GstFormat dest_format, gint64 * dest_value); +static GstCaps *gst_flac_parse_get_sink_caps (GstBaseParse * parse); GST_BOILERPLATE (GstFlacParse, gst_flac_parse, GstBaseParse, GST_TYPE_BASE_PARSE); @@ -248,6 +249,8 @@ gst_flac_parse_class_init (GstFlacParseClass * klass) baseparse_class->pre_push_frame = GST_DEBUG_FUNCPTR (gst_flac_parse_pre_push_frame); baseparse_class->convert = GST_DEBUG_FUNCPTR (gst_flac_parse_convert); + baseparse_class->get_sink_caps = + GST_DEBUG_FUNCPTR (gst_flac_parse_get_sink_caps); } static void @@ -1425,3 +1428,36 @@ gst_flac_parse_convert (GstBaseParse * parse, return GST_BASE_PARSE_CLASS (parent_class)->convert (parse, src_format, src_value, dest_format, dest_value); } + +static GstCaps * +gst_flac_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 field */ + 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"); + } + + 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; +} -- 2.7.4