summaryrefslogtreecommitdiff
path: root/test/v4l2_videodevice
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-07-09 13:56:55 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-07-14 16:00:51 +0300
commit9bb36ec274da530e509fe2f4010b262c43e812f3 (patch)
tree1b422e3abc7d7fcd801ae1df8704f1a138c290ca /test/v4l2_videodevice
parent33d3c4e2046044ec595ac2cb7ee7db4011e83fb7 (diff)
libcamera: v4l2_videodevice: Add helper to queue all buffers
When starting the stream on a capture video device it is often needed to queue all the allocated buffers. Add a helper method to do so, and refactor the existing queueBuffer() method to make it clearer. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'test/v4l2_videodevice')
-rw-r--r--test/v4l2_videodevice/buffer_sharing.cpp9
-rw-r--r--test/v4l2_videodevice/capture_async.cpp9
2 files changed, 8 insertions, 10 deletions
diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp
index cc724b22..da052f34 100644
--- a/test/v4l2_videodevice/buffer_sharing.cpp
+++ b/test/v4l2_videodevice/buffer_sharing.cpp
@@ -117,11 +117,10 @@ protected:
capture_->bufferReady.connect(this, &BufferSharingTest::captureBufferReady);
output_->bufferReady.connect(this, &BufferSharingTest::outputBufferReady);
- /* Queue all the buffers to the capture device. */
- for (Buffer &buffer : pool_.buffers()) {
- if (capture_->queueBuffer(&buffer))
- return TestFail;
- }
+ std::vector<std::unique_ptr<Buffer>> buffers;
+ buffers = capture_->queueAllBuffers();
+ if (buffers.empty())
+ return TestFail;
ret = capture_->streamOn();
if (ret) {
diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp
index cea4fffb..4909f71a 100644
--- a/test/v4l2_videodevice/capture_async.cpp
+++ b/test/v4l2_videodevice/capture_async.cpp
@@ -46,11 +46,10 @@ protected:
capture_->bufferReady.connect(this, &CaptureAsyncTest::receiveBuffer);
- /* Queue all the buffers to the device. */
- for (Buffer &b : pool_.buffers()) {
- if (capture_->queueBuffer(&b))
- return TestFail;
- }
+ std::vector<std::unique_ptr<Buffer>> buffers;
+ buffers = capture_->queueAllBuffers();
gst_libcamera_stream_formats_to_caps(const StreamFormats &forma
pt">(unsigned int fourcc : formats.pixelformats()) { g_autoptr(GstStructure) bare_s = bare_structure_from_fourcc(fourcc); if (!bare_s) { GST_WARNING("Unsupported DRM format %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS(fourcc)); continue; } for (const Size &size : formats.sizes(fourcc)) { GstStructure *s = gst_structure_copy(bare_s); gst_structure_set(s, "width", G_TYPE_INT, size.width, "height", G_TYPE_INT, size.height, nullptr); gst_caps_append_structure(caps, s); } const SizeRange &range = formats.range(fourcc); if (range.hStep && range.vStep) { GstStructure *s = gst_structure_copy(bare_s); GValue val = G_VALUE_INIT; g_value_init(&val, GST_TYPE_INT_RANGE); gst_value_set_int_range_step(&val, range.min.width, range.max.width, range.hStep); gst_structure_set_value(s, "width", &val); gst_value_set_int_range_step(&val, range.min.height, range.max.height, range.vStep); gst_structure_set_value(s, "height", &val); g_value_unset(&val); gst_caps_append_structure(caps, s); } } return caps; }