summaryrefslogtreecommitdiff
path: root/subprojects
diff options
context:
space:
mode:
authorPiotr Brzeziński <piotr@centricular.com>2024-05-07 11:18:10 +0200
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2024-05-07 14:48:47 +0000
commita9378c048e8cf4ee66559e40d3a22324acc94f9b (patch)
tree13f79ac07fe8f0f10de692525e3ab9a9780d22c2 /subprojects
parent5d7d3c6c0fdf81ad21c9e71bffd1f44ee6959454 (diff)
audiovisualizer: Add simple pipeline unit test
Creates pipelines with each of our visualizer elements and runs them with 20 buffers from audiotestsrc. Added after a completely broken (segfaulting) synaescope went unnoticed for a while. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6800>
Diffstat (limited to 'subprojects')
-rw-r--r--subprojects/gst-plugins-bad/tests/check/elements/audiovisualizer.c106
-rw-r--r--subprojects/gst-plugins-bad/tests/check/meson.build1
2 files changed, 107 insertions, 0 deletions
diff --git a/subprojects/gst-plugins-bad/tests/check/elements/audiovisualizer.c b/subprojects/gst-plugins-bad/tests/check/elements/audiovisualizer.c
new file mode 100644
index 0000000000..1da3521584
--- /dev/null
+++ b/subprojects/gst-plugins-bad/tests/check/elements/audiovisualizer.c
@@ -0,0 +1,106 @@
+/* GStreamer
+ *
+ * Copyright (C) 2024 Piotr Brzeziński <piotr@centricular.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/check/gstcheck.h>
+
+static void
+eos_cb (GstBus * bus, GstMessage * message, GMainLoop * loop)
+{
+ GST_DEBUG ("Received EOS");
+ g_main_loop_quit (loop);
+}
+
+static void
+error_cb (GstBus * bus, GstMessage * message, GMainLoop * loop)
+{
+ GError *err = NULL;
+ gchar *dbg = NULL;
+
+ gst_message_parse_error (message, &err, &dbg);
+ g_error ("ERROR: %s\n%s\n", err->message, dbg);
+}
+
+static void
+test_element (const gchar * element)
+{
+ GstElement *pipeline;
+ GstBus *bus;
+ GError *error = NULL;
+ gchar *pipe_str;
+ GMainLoop *loop;
+
+ pipe_str =
+ g_strdup_printf
+ ("audiotestsrc num-buffers=20 ! audio/x-raw,format=S16LE,channels=2 ! %s ! fakesink",
+ element);
+
+ pipeline = gst_parse_launch (pipe_str, &error);
+ fail_unless (pipeline != NULL, "Could not create pipeline: %s",
+ error->message);
+ g_free (pipe_str);
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ bus = gst_element_get_bus (pipeline);
+ fail_if (bus == NULL);
+ gst_bus_add_signal_watch (bus);
+ g_signal_connect (bus, "message::eos", (GCallback) eos_cb, loop);
+ g_signal_connect (bus, "message::error", (GCallback) error_cb, loop);
+
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ g_main_loop_run (loop);
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+
+ g_main_loop_unref (loop);
+ gst_object_unref (bus);
+ gst_object_unref (pipeline);
+}
+
+GST_START_TEST (test_simple_pipelines)
+{
+ /* Simple pipeline tests to see if these elements run at all.
+ * Will help catch breakages like https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6800. */
+ test_element ("wavescope");
+ test_element ("spacescope");
+ test_element ("spectrascope");
+ test_element ("synaescope");
+}
+
+GST_END_TEST;
+
+static Suite *
+audiovisualizer_suite (void)
+{
+ Suite *s = suite_create ("audiovisualizer");
+ TCase *tc_chain = tcase_create ("general");
+
+ suite_add_tcase (s, tc_chain);
+#ifndef GST_DISABLE_PARSE
+ tcase_add_test (tc_chain, test_simple_pipelines);
+#endif
+
+ return s;
+}
+
+GST_CHECK_MAIN (audiovisualizer);
diff --git a/subprojects/gst-plugins-bad/tests/check/meson.build b/subprojects/gst-plugins-bad/tests/check/meson.build
index 2605a1b82b..cedfed6be7 100644
--- a/subprojects/gst-plugins-bad/tests/check/meson.build
+++ b/subprojects/gst-plugins-bad/tests/check/meson.build
@@ -25,6 +25,7 @@ base_tests = [
[['elements/aesdec.c'], not aes_dep.found(), [aes_dep]],
[['elements/aiffparse.c'], get_option('aiff').disabled()],
[['elements/asfmux.c'], get_option('asfmux').disabled()],
+ [['elements/audiovisualizer.c'], get_option('audiovisualizers').disabled()],
[['elements/autoconvert.c'], get_option('autoconvert').disabled()],
[['elements/autovideoconvert.c'], get_option('autoconvert').disabled()],
[['elements/avwait.c'], get_option('timecode').disabled()],