From: Sebastian Dröge Date: Thu, 24 Nov 2011 08:59:40 +0000 (+0100) Subject: mpegaudioparse: Implement ::get_sink_caps vfunc to propagate downstream caps constrai... X-Git-Tag: RELEASE-0.11.1~7^2~183 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c114e7c073c5da7c46f06c6c908383f3b0f0d3e1;p=platform%2Fupstream%2Fgst-plugins-good.git mpegaudioparse: Implement ::get_sink_caps vfunc to propagate downstream caps constraints upstream --- diff --git a/gst/audioparsers/gstmpegaudioparse.c b/gst/audioparsers/gstmpegaudioparse.c index d816fff..25e373c 100644 --- a/gst/audioparsers/gstmpegaudioparse.c +++ b/gst/audioparsers/gstmpegaudioparse.c @@ -100,6 +100,7 @@ static GstFlowReturn gst_mpeg_audio_parse_pre_push_frame (GstBaseParse * parse, static gboolean gst_mpeg_audio_parse_convert (GstBaseParse * parse, GstFormat src_format, gint64 src_value, GstFormat dest_format, gint64 * dest_value); +static GstCaps *gst_mpeg_audio_parse_get_sink_caps (GstBaseParse * parse); GST_BOILERPLATE (GstMpegAudioParse, gst_mpeg_audio_parse, GstBaseParse, GST_TYPE_BASE_PARSE); @@ -177,6 +178,8 @@ gst_mpeg_audio_parse_class_init (GstMpegAudioParseClass * klass) parse_class->pre_push_frame = GST_DEBUG_FUNCPTR (gst_mpeg_audio_parse_pre_push_frame); parse_class->convert = GST_DEBUG_FUNCPTR (gst_mpeg_audio_parse_convert); + parse_class->get_sink_caps = + GST_DEBUG_FUNCPTR (gst_mpeg_audio_parse_get_sink_caps); /* register tags */ #define GST_TAG_CRC "has-crc" @@ -1269,3 +1272,36 @@ gst_mpeg_audio_parse_pre_push_frame (GstBaseParse * parse, return GST_FLOW_OK; } + +static GstCaps * +gst_mpeg_audio_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 parsed 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, "parsed"); + } + + 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; +}