test: gstreamer: Simplify single stream test

The single stream test for the GStreamer component has a simple pipeline
construction using only a fakesink.

The implementation currently supports connecting to a more complex
stream construction defined by the streamDescription, but this is over
engineered for the simple need to start a stream to capture and discard
the frames.

Convert the use of gst_parse_bin_from_description_full() which uses only
a single element 'fakesink' to construct the fakesink directly and link
it to the libcamerasrc.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Nicolas Dufresne 2024-03-05 10:30:57 -05:00 committed by Laurent Pinchart
parent 467bd6268d
commit a2a61121eb

View file

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