summaryrefslogtreecommitdiff
path: root/test/gstreamer
diff options
context:
space:
mode:
Diffstat (limited to 'test/gstreamer')
-rw-r--r--test/gstreamer/gstreamer_multi_stream_test.cpp20
-rw-r--r--test/gstreamer/gstreamer_test.cpp33
-rw-r--r--test/gstreamer/gstreamer_test.h5
3 files changed, 37 insertions, 21 deletions
diff --git a/test/gstreamer/gstreamer_multi_stream_test.cpp b/test/gstreamer/gstreamer_multi_stream_test.cpp
index 112f1dee..b8387c10 100644
--- a/test/gstreamer/gstreamer_multi_stream_test.cpp
+++ b/test/gstreamer/gstreamer_multi_stream_test.cpp
@@ -29,7 +29,7 @@ class GstreamerMultiStreamTest : public GstreamerTest, public Test
{
public:
GstreamerMultiStreamTest()
- : GstreamerTest()
+ : GstreamerTest(2)
{
}
@@ -39,24 +39,6 @@ protected:
if (status_ != TestPass)
return status_;
- /* Check if platform supports multistream capture */
- libcamera::CameraManager cm;
- cm.start();
- bool cameraFound = false;
- for (auto &camera : cm.cameras()) {
- if (camera->streams().size() > 1) {
- cameraName_ = camera->id();
- cameraFound = true;
- cm.stop();
- break;
- }
- }
-
- if (!cameraFound) {
- cm.stop();
- return TestSkip;
- }
-
const gchar *streamDescription = "queue ! fakesink";
g_autoptr(GError) error = NULL;
diff --git a/test/gstreamer/gstreamer_test.cpp b/test/gstreamer/gstreamer_test.cpp
index cfb8afc6..4947b7bb 100644
--- a/test/gstreamer/gstreamer_test.cpp
+++ b/test/gstreamer/gstreamer_test.cpp
@@ -5,6 +5,8 @@
* libcamera Gstreamer element API tests
*/
+#include <libcamera/libcamera.h>
+
#include <libcamera/base/utils.h>
#include "gstreamer_test.h"
@@ -25,7 +27,7 @@ const char *__asan_default_options()
}
}
-GstreamerTest::GstreamerTest()
+GstreamerTest::GstreamerTest(unsigned int numStreams)
: pipeline_(nullptr), libcameraSrc_(nullptr)
{
/*
@@ -67,9 +69,38 @@ GstreamerTest::GstreamerTest()
return;
}
+ /*
+ * Atleast one camera should be available with numStreams streams,
+ * otherwise skip the test entirely.
+ */
+ if (!checkMinCameraStreams(numStreams)) {
+ status_ = TestSkip;
+ return;
+ }
+
status_ = TestPass;
}
+bool GstreamerTest::checkMinCameraStreams(unsigned int numStreams)
+{
+ libcamera::CameraManager cm;
+ bool cameraFound = false;
+
+ cm.start();
+
+ for (auto &camera : cm.cameras()) {
+ if (camera->streams().size() < numStreams)
+ continue;
+
+ cameraFound = true;
+ break;
+ }
+
+ cm.stop();
+
+ return cameraFound;
+}
+
GstreamerTest::~GstreamerTest()
{
g_clear_object(&pipeline_);
diff --git a/test/gstreamer/gstreamer_test.h b/test/gstreamer/gstreamer_test.h
index 35adab0e..6f277cc5 100644
--- a/test/gstreamer/gstreamer_test.h
+++ b/test/gstreamer/gstreamer_test.h
@@ -15,7 +15,7 @@
class GstreamerTest
{
public:
- GstreamerTest();
+ GstreamerTest(unsigned int numStreams = 1);
virtual ~GstreamerTest();
protected:
@@ -27,4 +27,7 @@ protected:
GstElement *pipeline_;
GstElement *libcameraSrc_;
int status_;
+
+private:
+ bool checkMinCameraStreams(unsigned int numStreams);
};