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.
This commit is contained in:
Sebastian Dröge 2012-06-05 09:18:12 +02:00
parent 23520e4127
commit ca4b5d795b
7 changed files with 114 additions and 24 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}