summaryrefslogtreecommitdiff
path: root/test/v4l2_videodevice/v4l2_m2mdevice.cpp
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-12-18 18:47:45 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-01-12 16:10:37 +0100
commitf0d928b56eb3cf34bd61a94ccdaeedafd8108c49 (patch)
treecace3dc35ca1614f15c5f1c3aaee839a4ceb4a13 /test/v4l2_videodevice/v4l2_m2mdevice.cpp
parentcadae67e45785dc5dc005adb63c2dec841f44b1d (diff)
test: v4l2_videodevice: Switch to FrameBuffer interface
The V4L2VideoDevice class can now operate using a FrameBuffer interface, switch all test cases to use it. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'test/v4l2_videodevice/v4l2_m2mdevice.cpp')
-rw-r--r--test/v4l2_videodevice/v4l2_m2mdevice.cpp44
1 files changed, 18 insertions, 26 deletions
diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp
index 442bcac5..43b99c4f 100644
--- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp
+++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp
@@ -29,7 +29,7 @@ public:
{
}
- void outputBufferComplete(Buffer *buffer)
+ void outputBufferComplete(FrameBuffer *buffer)
{
cout << "Received output buffer" << endl;
@@ -39,7 +39,7 @@ public:
vim2m_->output()->queueBuffer(buffer);
}
- void receiveCaptureBuffer(Buffer *buffer)
+ void receiveCaptureBuffer(FrameBuffer *buffer)
{
cout << "Received capture buffer" << endl;
@@ -112,39 +112,31 @@ protected:
return TestFail;
}
- capturePool_.createBuffers(bufferCount);
- outputPool_.createBuffers(bufferCount);
-
- ret = capture->exportBuffers(&capturePool_);
- if (ret) {
+ ret = capture->exportBuffers(bufferCount, &captureBuffers_);
+ if (ret < 0) {
cerr << "Failed to export Capture Buffers" << endl;
return TestFail;
}
- ret = output->exportBuffers(&outputPool_);
- if (ret) {
+ ret = output->exportBuffers(bufferCount, &outputBuffers_);
+ if (ret < 0) {
cerr << "Failed to export Output Buffers" << endl;
return TestFail;
}
- capture->bufferReady.connect(this, &V4L2M2MDeviceTest::receiveCaptureBuffer);
- output->bufferReady.connect(this, &V4L2M2MDeviceTest::outputBufferComplete);
+ capture->frameBufferReady.connect(this, &V4L2M2MDeviceTest::receiveCaptureBuffer);
+ output->frameBufferReady.connect(this, &V4L2M2MDeviceTest::outputBufferComplete);
- std::vector<std::unique_ptr<Buffer>> captureBuffers;
- captureBuffers = capture->queueAllBuffers();
- if (captureBuffers.empty()) {
- cerr << "Failed to queue all Capture Buffers" << endl;
- return TestFail;
+ for (const std::unique_ptr<FrameBuffer> &buffer : captureBuffers_) {
+ if (capture->queueBuffer(buffer.get())) {
+ std::cout << "Failed to queue capture buffer" << std::endl;
+ return TestFail;
+ }
}
- /* We can't "queueAllBuffers()" on an output device, so we do it manually */
- std::vector<std::unique_ptr<Buffer>> outputBuffers;
- for (unsigned int i = 0; i < outputPool_.count(); ++i) {
- Buffer *buffer = new Buffer(i);
- outputBuffers.emplace_back(buffer);
- ret = output->queueBuffer(buffer);
- if (ret) {
- cerr << "Failed to queue output buffer" << i << endl;
+ for (const std::unique_ptr<FrameBuffer> &buffer : outputBuffers_) {
+ if (output->queueBuffer(buffer.get())) {
+ std::cout << "Failed to queue output buffer" << std::endl;
return TestFail;
}
}
@@ -202,8 +194,8 @@ private:
std::shared_ptr<MediaDevice> media_;
V4L2M2MDevice *vim2m_;
- BufferPool capturePool_;
- BufferPool outputPool_;
+ std::vector<std::unique_ptr<FrameBuffer>> captureBuffers_;
+ std::vector<std::unique_ptr<FrameBuffer>> outputBuffers_;
unsigned int outputFrames_;
unsigned int captureFrames_;