summaryrefslogtreecommitdiff
path: root/src/qcam/assets/feathericons/x-square.svg
blob: 7677c38718c00e7cf2ba0fe927a53dc1ce0c6f56 (plain)
1
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x-square"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="9" y1="9" x2="15" y2="15"></line><line x1="15" y1="9" x2="9" y2="15"></line></svg>
lass="hl com"> */ #include <iostream> #include <libcamera/buffer.h> #include <libcamera/event_dispatcher.h> #include <libcamera/timer.h> #include "thread.h" #include "v4l2_videodevice_test.h" class CaptureAsyncTest : public V4L2VideoDeviceTest { public: CaptureAsyncTest() : V4L2VideoDeviceTest("vimc", "Raw Capture 0"), frames(0) {} void receiveBuffer(Buffer *buffer) { std::cout << "Buffer received" << std::endl; frames++; /* Requeue the buffer for further use. */ capture_->queueBuffer(buffer); } protected: int run() { const unsigned int bufferCount = 8; EventDispatcher *dispatcher = Thread::current()->eventDispatcher(); Timer timeout; int ret; pool_.createBuffers(bufferCount); ret = capture_->exportBuffers(&pool_); if (ret) return TestFail; capture_->bufferReady.connect(this, &CaptureAsyncTest::receiveBuffer); std::vector<std::unique_ptr<Buffer>> buffers; buffers = capture_->queueAllBuffers(); if (buffers.empty()) return TestFail; ret = capture_->streamOn(); if (ret) return TestFail; timeout.start(10000); while (timeout.isRunning()) { dispatcher->processEvents(); if (frames > 30) break; } if (frames < 1) { std::cout << "Failed to capture any frames within timeout." << std::endl; return TestFail; } if (frames < 30) { std::cout << "Failed to capture 30 frames within timeout." << std::endl; return TestFail; } std::cout << "Processed " << frames << " frames" << std::endl; ret = capture_->streamOff(); if (ret) return TestFail; return TestPass; } private: unsigned int frames; }; TEST_REGISTER(CaptureAsyncTest);