@@ -209,6 +209,26 @@ TEST_P(MultiStream, Capture)
capture.capture(numRequests, NumStreams);
}
+/*
+ * Test optional stream capture cycles
+ *
+ * Do not provide buffers for all streams in all Requests, testing that stream
+ * output can be optional.
+ */
+TEST_P(MultiStream, CaptureOptional)
+{
+ constexpr unsigned int NumStreams = 2;
+
+ auto [roles, numRequests] = GetParam();
+
+ MultiCaptureOptional capture(camera_);
+
+ capture.configure({ roles.first, roles.second });
+
+ capture.capture(numRequests, NumStreams, 0);
+ capture.capture(numRequests, NumStreams, 1);
+}
+
INSTANTIATE_TEST_SUITE_P(MultiCaptureTests,
MultiStream,
testing::Combine(testing::ValuesIn(MULTIROLES),
@@ -185,3 +185,56 @@ void MultiCapture::requestComplete(Request *request)
if (queueRequest(request))
loop_->exit(-EINVAL);
}
+
+/* MultiCaptureOptional */
+
+MultiCaptureOptional::MultiCaptureOptional(std::shared_ptr<Camera> camera)
+ : MultiCapture(camera)
+{
+}
+
+void MultiCaptureOptional::capture(unsigned int numRequests, unsigned int numStreams,
+ unsigned int optionalStream)
+{
+ start();
+
+ queueCount_ = 0;
+ captureCount_ = 0;
+ captureLimit_ = numRequests;
+
+ std::vector<const FrameBufferList *>
+ buffers = prepareBuffers(numRequests, numStreams);
+
+ if (!buffers.size())
+ GTEST_SKIP();
+
+ /* Queue the recommended number of requests. */
+ const unsigned int inFlightRequests = config_->at(0).bufferCount;
+ for (unsigned int i = 0; i < inFlightRequests; i++) {
+ std::unique_ptr<Request> request = camera_->createRequest();
+ ASSERT_TRUE(request) << "Can't create request";
+
+ for (unsigned int j = 0; j < numStreams; j++) {
+ const FrameBufferList *bufferList = buffers[j];
+ Stream *stream = config_->at(j).stream();
+
+ if (j == optionalStream && !i)
+ continue;
+
+ ASSERT_EQ(request->addBuffer(stream, (*bufferList)[i].get()), 0)
+ << "Can't set buffer for request";
+ }
+
+ ASSERT_EQ(queueRequest(request.get()), 0)
+ << "Failed to queue request";
+ requests_.push_back(std::move(request));
+ }
+
+ /* Run capture session. */
+ loop_ = new EventLoop();
+ loop_->exec();
+ stop();
+ delete loop_;
+
+ ASSERT_EQ(captureCount_, captureLimit_);
+}
@@ -59,3 +59,12 @@ protected:
unsigned int captureCount_;
unsigned int captureLimit_;
};
+
+class MultiCaptureOptional : public MultiCapture
+{
+public:
+ MultiCaptureOptional(std::shared_ptr<libcamera::Camera> camera);
+
+ void capture(unsigned int numRequests, unsigned int numStreams,
+ unsigned int optionalStream);
+};
Add a new test class, MultiCaptureOptional. This tests operating with multiple streams, where one of the two streams is not provided buffers in certain requests. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> --- src/apps/lc-compliance/capture_test.cpp | 20 +++++++++ src/apps/lc-compliance/multi_capture.cpp | 53 ++++++++++++++++++++++++ src/apps/lc-compliance/multi_capture.h | 9 ++++ 3 files changed, 82 insertions(+)