From ca4b5d795bf52ea434470475e2dac6a149282c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 5 Jun 2012 09:18:12 +0200 Subject: [PATCH] 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. --- gst/audioparsers/gstaacparse.c | 22 +++++++++++++++++----- gst/audioparsers/gstac3parse.c | 22 ++++++++++++++++++---- gst/audioparsers/gstamrparse.c | 18 +++++++++++++++--- gst/audioparsers/gstdcaparse.c | 19 ++++++++++++++++--- gst/audioparsers/gstflacparse.c | 19 ++++++++++++++++--- gst/audioparsers/gstmpegaudioparse.c | 19 ++++++++++++++++--- gst/audioparsers/gstwavpackparse.c | 19 ++++++++++++++++--- 7 files changed, 114 insertions(+), 24 deletions(-) diff --git a/gst/audioparsers/gstaacparse.c b/gst/audioparsers/gstaacparse.c index b0820768cc..f56b3e8374 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 26ee0d8b43..e6ac16b04c 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 530f025634..2bcb08542b 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 2b6aafb752..3d44b65c87 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 5ca2ca1804..bc0beaa25d 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 b028be16b4..03be43854e 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 c3bcb68068..e11f82afa7 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; }