@@ -229,6 +229,27 @@ TEST_P(MultiStream, CaptureOptional)
capture.capture(numRequests, NumStreams, 1);
}
+/*
+ * Test mandatory stream hints
+ *
+ * Mark a single stream as mandatory, and don't provide a buffer for it in the
+ * request. This should case the queueRequest call to fail.
+ */
+TEST_P(MultiStream, CaptureHints)
+{
+ constexpr unsigned int NumStreams = 2;
+
+ auto [roles, numRequests] = GetParam();
+
+ MultiCaptureHints capture0(camera_, 0);
+ capture0.configure({ roles.first, roles.second });
+ capture0.capture(NumStreams);
+
+ MultiCaptureHints capture1(camera_, 1);
+ capture1.configure({ roles.first, roles.second });
+ capture1.capture(NumStreams);
+}
+
INSTANTIATE_TEST_SUITE_P(MultiCaptureTests,
MultiStream,
testing::Combine(testing::ValuesIn(MULTIROLES),
@@ -238,3 +238,51 @@ void MultiCaptureOptional::capture(unsigned int numRequests, unsigned int numStr
ASSERT_EQ(captureCount_, captureLimit_);
}
+
+/* MultiCaptureHints */
+
+MultiCaptureHints::MultiCaptureHints(std::shared_ptr<Camera> camera,
+ unsigned int mandatoryStream)
+ : MultiCaptureBase(camera), mandatoryStream_(mandatoryStream)
+{
+}
+
+void MultiCaptureHints::capture(unsigned int numStreams)
+{
+ start();
+
+ std::vector<const FrameBufferList *>
+ buffers = prepareBuffers(config_->at(0).bufferCount, numStreams);
+
+ if (!buffers.size())
+ GTEST_SKIP();
+
+ /* Queue a single request */
+ 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();
+
+ /*
+ * Do not add a buffer for the mandatory stream to cause a
+ * deliberate failure.
+ */
+ if (j == mandatoryStream_)
+ continue;
+
+ ASSERT_EQ(request->addBuffer(stream, (*bufferList)[0].get()), 0)
+ << "Can't set buffer for request";
+ }
+
+ ASSERT_EQ(camera_->queueRequest(request.get()), -ENOMEM)
+ << "queueRequest did not fail!";
+
+ stop();
+}
+
+void MultiCaptureHints::updateConfig()
+{
+ config_.get()->at(mandatoryStream_).hints = StreamConfiguration::Hint::MandatoryStream;
+}
@@ -68,3 +68,20 @@ public:
void capture(unsigned int numRequests, unsigned int numStreams,
unsigned int optionalStream);
};
+
+class MultiCaptureHints : public MultiCaptureBase
+{
+public:
+ MultiCaptureHints(std::shared_ptr<libcamera::Camera> camera,
+ unsigned int mandatoryStream);
+
+ void capture(unsigned int numStreams);
+
+private:
+ void updateConfig() override;
+ void requestComplete([[maybe_unused]] libcamera::Request *request) override
+ {
+ }
+
+ unsigned int mandatoryStream_;
+};
Add a new test class, MultiCaptureHints. This tests the MandatoryStream hint flag and ensures that requests are cancelled correctly if the flag is set and no buffer is provided. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> --- src/apps/lc-compliance/capture_test.cpp | 21 +++++++++++ src/apps/lc-compliance/multi_capture.cpp | 48 ++++++++++++++++++++++++ src/apps/lc-compliance/multi_capture.h | 17 +++++++++ 3 files changed, 86 insertions(+)