[v1,2/3] test: gstreamer: Simplify single stream test
diff mbox series

Message ID 20240227175336.560009-3-nicolas@ndufresne.ca
State Accepted
Headers show
Series
  • gstreamer: Fix a crash when memory outlives the pipeline
Related show

Commit Message

Nicolas Dufresne Feb. 27, 2024, 5:53 p.m. UTC
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
 .../gstreamer_single_stream_test.cpp          | 27 +++++++------------
 1 file changed, 9 insertions(+), 18 deletions(-)

Patch
diff mbox series

diff --git a/test/gstreamer/gstreamer_single_stream_test.cpp b/test/gstreamer/gstreamer_single_stream_test.cpp
index 301e4a93..815c6609 100644
--- a/test/gstreamer/gstreamer_single_stream_test.cpp
+++ b/test/gstreamer/gstreamer_single_stream_test.cpp
@@ -29,30 +29,21 @@  protected:
 		if (status_ != TestPass)
 			return status_;
 
-		const gchar *streamDescription = "fakesink";
-		g_autoptr(GError) error0 = NULL;
-		stream0_ = gst_parse_bin_from_description_full(streamDescription, TRUE,
-						NULL,
-						GST_PARSE_FLAG_FATAL_ERRORS,
-						&error0);
-
-		if (!stream0_) {
-			g_printerr("Bin could not be created (%s)\n", error0->message);
+		fakesink_ = gst_element_factory_make("fakesink", nullptr);
+		if (!fakesink_) {
+			g_printerr("Your installation is missing 'fakesink'\n");
 			return TestFail;
 		}
-		g_object_ref_sink(stream0_);
-
-		if (createPipeline() != TestPass)
-			return TestFail;
+		g_object_ref_sink(fakesink_);
 
-		return TestPass;
+		return createPipeline();
 	}
 
 	int run() override
 	{
 		/* Build the pipeline */
-		gst_bin_add_many(GST_BIN(pipeline_), libcameraSrc_, stream0_, NULL);
-		if (gst_element_link(libcameraSrc_, stream0_) != TRUE) {
+		gst_bin_add_many(GST_BIN(pipeline_), libcameraSrc_, fakesink_, nullptr);
+		if (!gst_element_link(libcameraSrc_, fakesink_)) {
 			g_printerr("Elements could not be linked.\n");
 			return TestFail;
 		}
@@ -68,11 +59,11 @@  protected:
 
 	void cleanup() override
 	{
-		g_clear_object(&stream0_);
+		g_clear_object(&fakesink_);
 	}
 
 private:
-	GstElement *stream0_;
+	GstElement *fakesink_;
 };
 
 TEST_REGISTER(GstreamerSingleStreamTest)