{"id":497,"url":"https://patchwork.libcamera.org/api/1.1/patches/497/?format=json","web_url":"https://patchwork.libcamera.org/patch/497/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190203110102.5663-11-kieran.bingham@ideasonboard.com>","date":"2019-02-03T11:01:01","name":"[libcamera-devel,10/11] test: v4l2_device: Provide asynchronous capture test","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"61e847ea8d63283e95e87f8fe061f8a0f7a4ad58","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/497/mbox/","series":[{"id":165,"url":"https://patchwork.libcamera.org/api/1.1/series/165/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=165","date":"2019-02-03T11:00:51","name":"libcamera: V4L2 Streams","version":1,"mbox":"https://patchwork.libcamera.org/series/165/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/497/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/497/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0FFF760DD6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  3 Feb 2019 12:01:09 +0100 (CET)","from localhost.localdomain\n\t(218.182-78-194.adsl-static.isp.belgacom.be [194.78.182.218])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B1B0C41;\n\tSun,  3 Feb 2019 12:01:08 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1549191668;\n\tbh=oDxTNucYy3vOWg1TqMKzYuhw/t7U6/nsw1sEYLipvrg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=qd43pd34Hdx/YSHHDaVFFbtHILlpv3XzdFwb6DN5SvXPX6CAFbwnzmGg2orfo02hk\n\tAyTuw0j+ZdzAerOZeO4aQKX1bwf26MQFeqyYnLcqPu++weFXgSPK1plXAe7EzXsxc3\n\tyk1TJBYcg1YDUA43b8fIdqJ+JC68F1ANEjtZSNXY=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Date":"Sun,  3 Feb 2019 12:01:01 +0100","Message-Id":"<20190203110102.5663-11-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.19.1","In-Reply-To":"<20190203110102.5663-1-kieran.bingham@ideasonboard.com>","References":"<20190203110102.5663-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 10/11] test: v4l2_device: Provide\n\tasynchronous capture test","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sun, 03 Feb 2019 11:01:10 -0000"},"content":"Utilise the event_dispatcher to create a default event loop, and process\nasynchronous buffer receive events.\n\nIf no frames are captured in 5 seconds, the test will fail.\nIt will also fail if less than 30 frames have been captured int the same\ntimeout period.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n test/v4l2_device/capture_async.cpp | 69 ++++++++++++++++++++++++++++++\n test/v4l2_device/meson.build       |  1 +\n 2 files changed, 70 insertions(+)\n create mode 100644 test/v4l2_device/capture_async.cpp","diff":"diff --git a/test/v4l2_device/capture_async.cpp b/test/v4l2_device/capture_async.cpp\nnew file mode 100644\nindex 000000000000..70f340dba3f1\n--- /dev/null\n+++ b/test/v4l2_device/capture_async.cpp\n@@ -0,0 +1,69 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * libcamera V4L2 API tests\n+ */\n+\n+#include <libcamera/buffer.h>\n+#include <libcamera/camera_manager.h>\n+#include <libcamera/event_dispatcher.h>\n+#include <libcamera/timer.h>\n+\n+#include <iostream>\n+\n+#include \"v4l2_device_test.h\"\n+\n+class CaptureAsync : public V4L2DeviceTest\n+{\n+public:\n+\tCaptureAsync()\n+\t\t: frames(0){};\n+\n+\tvoid ReceiveBuffer(Buffer *buffer)\n+\t{\n+\t\tstd::cout << \"Received a Buffer\" << std::endl;\n+\t\tframes++;\n+\t}\n+\n+protected:\n+\tint run()\n+\t{\n+\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tTimer timeout;\n+\t\tint ret;\n+\n+\t\tBufferPool *pool = dev_->requestBuffers(8);\n+\t\tif (!pool)\n+\t\t\treturn TestFail;\n+\n+\t\tdev_->bufferReady.connect(this, &CaptureAsync::ReceiveBuffer);\n+\n+\t\tret = dev_->streamOn();\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\ttimeout.start(5000);\n+\t\twhile (timeout.isRunning())\n+\t\t\tdispatcher->processEvents();\n+\n+\t\tif (frames < 1) {\n+\t\t\tstd::cout << \"Failed to capture any frames within timeout.\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (frames < 30) {\n+\t\t\tstd::cout << \"Failed to capture 30 frames within timeout.\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tstd::cout << \"Processed \" << frames << \" frames\" << std::endl;\n+\n+\t\treturn dev_->streamOff();\n+\t}\n+\n+private:\n+\tunsigned int frames;\n+};\n+\n+TEST_REGISTER(CaptureAsync);\ndiff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build\nindex f04c7ded009c..2a37b7b06134 100644\n--- a/test/v4l2_device/meson.build\n+++ b/test/v4l2_device/meson.build\n@@ -5,6 +5,7 @@ v4l2_device_tests = [\n   [ 'request_buffers',    'request_buffers.cpp' ],\n   [ 'stream_on_off',      'stream_on_off.cpp' ],\n   [ 'capture_frames',     'capture_frames.cpp' ],\n+  [ 'capture_async',      'capture_async.cpp' ],\n ]\n \n foreach t : v4l2_device_tests\n","prefixes":["libcamera-devel","10/11"]}