wavparse: handle query in any parse state

In order to create the stream_id, we need to
pass the query to the default query handler.

If the parse state is different from GST_WAVPARSE_DATA
the query should be passed to the default query
handler.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1987>
This commit is contained in:
Stéphane Cerveau 2022-03-18 15:20:49 +01:00 committed by GStreamer Marge Bot
parent 074f7c2e4e
commit 1170ab3c29
2 changed files with 35 additions and 5 deletions

View file

@ -2657,13 +2657,12 @@ gst_wavparse_pad_query (GstPad * pad, GstObject * parent, GstQuery * query)
gboolean res = TRUE;
GstWavParse *wav = GST_WAVPARSE (parent);
/* only if we know */
if (wav->state != GST_WAVPARSE_DATA) {
return FALSE;
}
GST_LOG_OBJECT (pad, "%s query", GST_QUERY_TYPE_NAME (query));
if (wav->state != GST_WAVPARSE_DATA) {
return gst_pad_query_default (pad, parent, query);
}
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION:
{

View file

@ -209,6 +209,36 @@ GST_START_TEST (test_seek)
GST_END_TEST;
GST_START_TEST (test_query_uri)
{
GstElement *pipeline, *filesrc, *wavparse, *fakesink;
GstQuery *query;
gchar *uri;
fail_unless ((pipeline = gst_pipeline_new (NULL)) != NULL,
"Could not create pipeline");
fail_unless ((filesrc = gst_element_factory_make ("filesrc", NULL)) != NULL,
"Could not create filesrc");
fail_unless ((wavparse = gst_element_factory_make ("wavparse", NULL)) != NULL,
"Could not create wavparse");
fail_unless ((fakesink = gst_element_factory_make ("fakesink", NULL)) != NULL,
"Could not create fakesink");
gst_bin_add_many (GST_BIN (pipeline), filesrc, wavparse, fakesink, NULL);
gst_element_link_many (filesrc, wavparse, fakesink, NULL);
g_object_set (G_OBJECT (filesrc), "location", "my_test_file", NULL);
fail_unless ((query = gst_query_new_uri ()) != NULL,
"Could not prepare uri query");
fail_unless (gst_element_query (GST_ELEMENT (wavparse), query),
"Could not query uri");
gst_query_parse_uri (query, &uri);
fail_unless (uri != NULL);
g_free (uri);
gst_query_unref (query);
gst_object_unref (pipeline);
}
GST_END_TEST;
static Suite *
wavparse_suite (void)
{
@ -221,6 +251,7 @@ wavparse_suite (void)
tcase_add_test (tc_chain, test_simple_file_pull);
tcase_add_test (tc_chain, test_simple_file_push);
tcase_add_test (tc_chain, test_seek);
tcase_add_test (tc_chain, test_query_uri);
return s;
}