wavparse: handle query in any parse state
authorStéphane Cerveau <scerveau@collabora.com>
Fri, 18 Mar 2022 14:20:49 +0000 (15:20 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 22 Mar 2022 16:25:35 +0000 (16:25 +0000)
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>

subprojects/gst-plugins-good/gst/wavparse/gstwavparse.c
subprojects/gst-plugins-good/tests/check/elements/wavparse.c

index 45b9db9..04dca3e 100644 (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 */
+  GST_LOG_OBJECT (pad, "%s query", GST_QUERY_TYPE_NAME (query));
+
   if (wav->state != GST_WAVPARSE_DATA) {
-    return FALSE;
+    return gst_pad_query_default (pad, parent, query);
   }
 
-  GST_LOG_OBJECT (pad, "%s query", GST_QUERY_TYPE_NAME (query));
-
   switch (GST_QUERY_TYPE (query)) {
     case GST_QUERY_POSITION:
     {
index 8a5702d..89e988b 100644 (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;
 }