From: Sebastian Dröge Date: Tue, 5 Jun 2012 07:18:12 +0000 (+0200) Subject: audioparsers: Fix GstBaseParse::get_sink_caps() implementations X-Git-Tag: RELEASE-0.11.92~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca4b5d795bf52ea434470475e2dac6a149282c10;p=platform%2Fupstream%2Fgst-plugins-good.git audioparsers: Fix GstBaseParse::get_sink_caps() implementations They should take the filter caps into account and always return the template caps appended to the actual caps. Otherwise the parsers stop to accept unparsed streams where upstream does not know about channels, rate, etc. Fixes bug #677401. --- diff --git a/gst/audioparsers/gstaacparse.c b/gst/audioparsers/gstaacparse.c index b082076..f56b3e8 100644 --- a/gst/audioparsers/gstaacparse.c +++ b/gst/audioparsers/gstaacparse.c @@ -1093,10 +1093,8 @@ gst_aac_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter) GstCaps *peercaps, *templ; GstCaps *res; - /* FIXME: handle filter caps */ - - templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)), - peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); + templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); + peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); if (peercaps) { guint i, n; @@ -1111,10 +1109,24 @@ gst_aac_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter) res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); - gst_caps_unref (templ); + + /* Append the template caps because we still want to accept + * caps without any fields in the case upstream does not + * know anything. + */ + gst_caps_append (res, templ); } else { res = templ; } + if (filter) { + GstCaps *intersection; + + intersection = + gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (res); + res = intersection; + } + return res; } diff --git a/gst/audioparsers/gstac3parse.c b/gst/audioparsers/gstac3parse.c index 26ee0d8..e6ac16b 100644 --- a/gst/audioparsers/gstac3parse.c +++ b/gst/audioparsers/gstac3parse.c @@ -696,9 +696,9 @@ gst_ac3_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) GstCaps *peercaps, *templ; GstCaps *res; - /* FIXME: handle filter */ - templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)), - peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); + templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); + peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (peercaps) { guint i, n; @@ -715,10 +715,24 @@ gst_ac3_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); - gst_caps_unref (templ); + + /* Append the template caps because we still want to accept + * caps without any fields in the case upstream does not + * know anything. + */ + gst_caps_append (res, templ); } else { res = templ; } + if (filter) { + GstCaps *intersection; + + intersection = + gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (res); + res = intersection; + } + return res; } diff --git a/gst/audioparsers/gstamrparse.c b/gst/audioparsers/gstamrparse.c index 530f025..2bcb085 100644 --- a/gst/audioparsers/gstamrparse.c +++ b/gst/audioparsers/gstamrparse.c @@ -368,11 +368,10 @@ gst_amr_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter) GstCaps *peercaps, *templ; GstCaps *res; - /* FIXME: handle filter caps */ templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); - peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (peercaps) { guint i, n; @@ -390,10 +389,23 @@ gst_amr_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter) res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); - gst_caps_unref (templ); + /* Append the template caps because we still want to accept + * caps without any fields in the case upstream does not + * know anything. + */ + gst_caps_append (res, templ); } else { res = templ; } + if (filter) { + GstCaps *intersection; + + intersection = + gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (res); + res = intersection; + } + return res; } diff --git a/gst/audioparsers/gstdcaparse.c b/gst/audioparsers/gstdcaparse.c index 2b6aafb..3d44b65 100644 --- a/gst/audioparsers/gstdcaparse.c +++ b/gst/audioparsers/gstdcaparse.c @@ -446,10 +446,9 @@ gst_dca_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) GstCaps *peercaps, *templ; GstCaps *res; - /* FIXME: handle filter caps */ templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); - peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (peercaps) { guint i, n; @@ -464,10 +463,24 @@ gst_dca_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); - gst_caps_unref (templ); + + /* Append the template caps because we still want to accept + * caps without any fields in the case upstream does not + * know anything. + */ + gst_caps_append (res, templ); } else { res = templ; } + if (filter) { + GstCaps *intersection; + + intersection = + gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (res); + res = intersection; + } + return res; } diff --git a/gst/audioparsers/gstflacparse.c b/gst/audioparsers/gstflacparse.c index 5ca2ca1..bc0beaa 100644 --- a/gst/audioparsers/gstflacparse.c +++ b/gst/audioparsers/gstflacparse.c @@ -1550,10 +1550,9 @@ gst_flac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) GstCaps *peercaps, *templ; GstCaps *res; - /* FIXME: handle filter caps */ templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); - peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (peercaps) { guint i, n; @@ -1568,10 +1567,24 @@ gst_flac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); - gst_caps_unref (templ); + + /* Append the template caps because we still want to accept + * caps without any fields in the case upstream does not + * know anything. + */ + gst_caps_append (res, templ); } else { res = templ; } + if (filter) { + GstCaps *intersection; + + intersection = + gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (res); + res = intersection; + } + return res; } diff --git a/gst/audioparsers/gstmpegaudioparse.c b/gst/audioparsers/gstmpegaudioparse.c index b028be1..03be438 100644 --- a/gst/audioparsers/gstmpegaudioparse.c +++ b/gst/audioparsers/gstmpegaudioparse.c @@ -1404,10 +1404,9 @@ gst_mpeg_audio_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) GstCaps *peercaps, *templ; GstCaps *res; - /* FIXME: handle filter caps */ templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); - peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (peercaps) { guint i, n; @@ -1422,10 +1421,24 @@ gst_mpeg_audio_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); - gst_caps_unref (templ); + + /* Append the template caps because we still want to accept + * caps without any fields in the case upstream does not + * know anything. + */ + gst_caps_append (res, templ); } else { res = templ; } + if (filter) { + GstCaps *intersection; + + intersection = + gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (res); + res = intersection; + } + return res; } diff --git a/gst/audioparsers/gstwavpackparse.c b/gst/audioparsers/gstwavpackparse.c index c3bcb68..e11f82a 100644 --- a/gst/audioparsers/gstwavpackparse.c +++ b/gst/audioparsers/gstwavpackparse.c @@ -614,10 +614,9 @@ gst_wavpack_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) GstCaps *peercaps, *templ; GstCaps *res; - /* FIXME: handle filter caps */ templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); - peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (peercaps) { guint i, n; @@ -632,10 +631,24 @@ gst_wavpack_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); - gst_caps_unref (templ); + + /* Append the template caps because we still want to accept + * caps without any fields in the case upstream does not + * know anything. + */ + gst_caps_append (res, templ); } else { res = templ; } + if (filter) { + GstCaps *intersection; + + intersection = + gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (res); + res = intersection; + } + return res; }