mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
audioparsers: use ACCEPT_INTERSECT flag
The parser can accept input that is not completely specified. Use the
ACCEPT_INTERSECT flag on the sinkpad to tweak the acceptcaps function to
check for intersection only. This allows us to proxy downstream
constraints while still allowing non-subset caps as input.
We can then also remove the appended template caps workaround.
Make a unit-test to check the new feature.
This reverts commit 26040ee38c
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=705024
This commit is contained in:
parent
e3f393f7e6
commit
e0a5c07e8d
9 changed files with 56 additions and 50 deletions
|
@ -143,6 +143,7 @@ static void
|
|||
gst_aac_parse_init (GstAacParse * aacparse)
|
||||
{
|
||||
GST_DEBUG ("initialized");
|
||||
GST_PAD_SET_ACCEPT_INTERSECT (GST_BASE_PARSE_SINK_PAD (aacparse));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1391,13 +1392,6 @@ gst_aac_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter)
|
|||
|
||||
res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
|
||||
gst_caps_unref (peercaps);
|
||||
res = gst_caps_make_writable (res);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -218,6 +218,7 @@ gst_ac3_parse_init (GstAc3Parse * ac3parse)
|
|||
gst_ac3_parse_reset (ac3parse);
|
||||
ac3parse->baseparse_chainfunc =
|
||||
GST_BASE_PARSE_SINK_PAD (GST_BASE_PARSE (ac3parse))->chainfunc;
|
||||
GST_PAD_SET_ACCEPT_INTERSECT (GST_BASE_PARSE_SINK_PAD (ac3parse));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -837,13 +838,6 @@ 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);
|
||||
res = gst_caps_make_writable (res);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ gst_amr_parse_init (GstAmrParse * amrparse)
|
|||
/* init rest */
|
||||
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (amrparse), 62);
|
||||
GST_DEBUG ("initialized");
|
||||
|
||||
GST_PAD_SET_ACCEPT_INTERSECT (GST_BASE_PARSE_SINK_PAD (amrparse));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -132,6 +132,8 @@ gst_dca_parse_init (GstDcaParse * dcaparse)
|
|||
gst_dca_parse_reset (dcaparse);
|
||||
dcaparse->baseparse_chainfunc =
|
||||
GST_BASE_PARSE_SINK_PAD (GST_BASE_PARSE (dcaparse))->chainfunc;
|
||||
|
||||
GST_PAD_SET_ACCEPT_INTERSECT (GST_BASE_PARSE_SINK_PAD (dcaparse));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -510,13 +512,6 @@ 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);
|
||||
res = gst_caps_make_writable (res);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -258,6 +258,7 @@ static void
|
|||
gst_flac_parse_init (GstFlacParse * flacparse)
|
||||
{
|
||||
flacparse->check_frame_checksums = DEFAULT_CHECK_FRAME_CHECKSUMS;
|
||||
GST_PAD_SET_ACCEPT_INTERSECT (GST_BASE_PARSE_SINK_PAD (flacparse));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1829,13 +1830,6 @@ 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);
|
||||
res = gst_caps_make_writable (res);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -225,6 +225,7 @@ static void
|
|||
gst_mpeg_audio_parse_init (GstMpegAudioParse * mp3parse)
|
||||
{
|
||||
gst_mpeg_audio_parse_reset (mp3parse);
|
||||
GST_PAD_SET_ACCEPT_INTERSECT (GST_BASE_PARSE_SINK_PAD (mp3parse));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1434,13 +1435,6 @@ 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);
|
||||
res = gst_caps_make_writable (res);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ static void
|
|||
gst_sbc_parse_init (GstSbcParse * sbcparse)
|
||||
{
|
||||
gst_sbc_parse_reset (sbcparse);
|
||||
GST_PAD_SET_ACCEPT_INTERSECT (GST_BASE_PARSE_SINK_PAD (sbcparse));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -335,13 +336,6 @@ gst_sbc_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
|
|||
|
||||
res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
|
||||
gst_caps_unref (peercaps);
|
||||
res = gst_caps_make_writable (res);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -117,6 +117,7 @@ static void
|
|||
gst_wavpack_parse_init (GstWavpackParse * wvparse)
|
||||
{
|
||||
gst_wavpack_parse_reset (wvparse);
|
||||
GST_PAD_SET_ACCEPT_INTERSECT (GST_BASE_PARSE_SINK_PAD (wvparse));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -644,13 +645,6 @@ 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);
|
||||
res = gst_caps_make_writable (res);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -185,6 +185,50 @@ GST_START_TEST (test_parse_handle_codec_data)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_parse_proxy_constraints)
|
||||
{
|
||||
GstCaps *caps;
|
||||
GstElement *parse, *filter;
|
||||
GstPad *sinkpad;
|
||||
GstStructure *s;
|
||||
|
||||
parse = gst_element_factory_make ("aacparse", NULL);
|
||||
filter = gst_element_factory_make ("capsfilter", NULL);
|
||||
|
||||
/* constraint on rate and version */
|
||||
caps = gst_caps_from_string ("audio/mpeg,mpegversion=2,rate=44100");
|
||||
g_object_set (filter, "caps", caps, NULL);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
gst_element_link (parse, filter);
|
||||
|
||||
sinkpad = gst_element_get_static_pad (parse, "sink");
|
||||
caps = gst_pad_query_caps (sinkpad, NULL);
|
||||
GST_LOG ("caps %" GST_PTR_FORMAT, caps);
|
||||
|
||||
fail_unless (gst_caps_get_size (caps) == 1);
|
||||
|
||||
/* getcaps should proxy the rate constraint */
|
||||
s = gst_caps_get_structure (caps, 0);
|
||||
fail_unless (gst_structure_has_name (s, "audio/mpeg"));
|
||||
fail_unless_structure_field_int_equals (s, "rate", 44100);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* should accept without the constraint */
|
||||
caps = gst_caps_from_string ("audio/mpeg,mpegversion=2");
|
||||
fail_unless (gst_pad_query_accept_caps (sinkpad, caps));
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* should not accept with conflicting version */
|
||||
caps = gst_caps_from_string ("audio/mpeg,mpegversion=4");
|
||||
fail_if (gst_pad_query_accept_caps (sinkpad, caps));
|
||||
gst_caps_unref (caps);
|
||||
|
||||
gst_object_unref (sinkpad);
|
||||
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
aacparse_suite (void)
|
||||
|
@ -207,6 +251,9 @@ aacparse_suite (void)
|
|||
/* Other tests */
|
||||
tcase_add_test (tc_chain, test_parse_handle_codec_data);
|
||||
|
||||
/* caps tests */
|
||||
tcase_add_test (tc_chain, test_parse_proxy_constraints);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue