test: gstreamer: Simplify single stream test using functions from GstUtils
Simplify memory handling and complexity of the test by using gst_parse_bin_from_description_full [1]. [1]: https://gstreamer.freedesktop.org/documentation/gstreamer/gstutils.html?gi-language=c#gst_parse_bin_from_description_full Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
ca9ea1f9ce
commit
fa9a9d7f6b
1 changed files with 13 additions and 17 deletions
|
@ -33,20 +33,18 @@ protected:
|
||||||
if (status_ != TestPass)
|
if (status_ != TestPass)
|
||||||
return status_;
|
return status_;
|
||||||
|
|
||||||
g_autoptr(GstElement) convert0 = gst_element_factory_make("videoconvert", "convert0");
|
const gchar *streamDescription = "videoconvert ! fakesink";
|
||||||
g_autoptr(GstElement) sink0 = gst_element_factory_make("fakesink", "sink0");
|
g_autoptr(GError) error0 = NULL;
|
||||||
g_object_ref_sink(convert0);
|
stream0_ = gst_parse_bin_from_description_full(streamDescription, TRUE,
|
||||||
g_object_ref_sink(sink0);
|
NULL,
|
||||||
|
GST_PARSE_FLAG_FATAL_ERRORS,
|
||||||
if (!convert0 || !sink0) {
|
&error0);
|
||||||
g_printerr("Not all elements could be created. %p.%p\n",
|
|
||||||
convert0, sink0);
|
|
||||||
|
|
||||||
|
if (!stream0_) {
|
||||||
|
g_printerr("Bin could not be created (%s)\n", error0->message);
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
|
g_object_ref_sink(stream0_);
|
||||||
convert0_ = reinterpret_cast<GstElement *>(g_steal_pointer(&convert0));
|
|
||||||
sink0_ = reinterpret_cast<GstElement *>(g_steal_pointer(&sink0));
|
|
||||||
|
|
||||||
if (createPipeline() != TestPass)
|
if (createPipeline() != TestPass)
|
||||||
return TestFail;
|
return TestFail;
|
||||||
|
@ -57,8 +55,8 @@ protected:
|
||||||
int run() override
|
int run() override
|
||||||
{
|
{
|
||||||
/* Build the pipeline */
|
/* Build the pipeline */
|
||||||
gst_bin_add_many(GST_BIN(pipeline_), libcameraSrc_, convert0_, sink0_, NULL);
|
gst_bin_add_many(GST_BIN(pipeline_), libcameraSrc_, stream0_, NULL);
|
||||||
if (gst_element_link_many(libcameraSrc_, convert0_, sink0_, NULL) != TRUE) {
|
if (gst_element_link(libcameraSrc_, stream0_) != TRUE) {
|
||||||
g_printerr("Elements could not be linked.\n");
|
g_printerr("Elements could not be linked.\n");
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
|
@ -74,13 +72,11 @@ protected:
|
||||||
|
|
||||||
void cleanup() override
|
void cleanup() override
|
||||||
{
|
{
|
||||||
g_clear_object(&convert0_);
|
g_clear_object(&stream0_);
|
||||||
g_clear_object(&sink0_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GstElement *convert0_;
|
GstElement *stream0_;
|
||||||
GstElement *sink0_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_REGISTER(GstreamerSingleStreamTest)
|
TEST_REGISTER(GstreamerSingleStreamTest)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue