Show a patch.

GET /api/patches/2876/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2876,
    "url": "https://patchwork.libcamera.org/api/patches/2876/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2876/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20200224193601.1040770-3-niklas.soderlund@ragnatech.se>",
    "date": "2020-02-24T19:35:59",
    "name": "[libcamera-devel,v2,2/4] test: Extract BufferSource class out of camera tests to libtest",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "afaab168648e74aa1305a9d64135873b660235f3",
    "submitter": {
        "id": 5,
        "url": "https://patchwork.libcamera.org/api/people/5/?format=api",
        "name": "Niklas Söderlund",
        "email": "niklas.soderlund@ragnatech.se"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2876/mbox/",
    "series": [
        {
            "id": 691,
            "url": "https://patchwork.libcamera.org/api/series/691/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=691",
            "date": "2020-02-24T19:35:57",
            "name": "libcamera: V4L2BufferCache: Improve cache eviction strategy",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/691/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2876/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2876/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<niklas.soderlund@ragnatech.se>",
        "Received": [
            "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A59216265B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Feb 2020 20:36:25 +0100 (CET)",
            "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid ee83490e-573c-11ea-9f40-0050569116f7;\n\tMon, 24 Feb 2020 20:36:20 +0100 (CET)"
        ],
        "X-Halon-ID": "ee83490e-573c-11ea-9f40-0050569116f7",
        "Authorized-sender": "niklas@soderlund.pp.se",
        "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 24 Feb 2020 20:35:59 +0100",
        "Message-Id": "<20200224193601.1040770-3-niklas.soderlund@ragnatech.se>",
        "X-Mailer": "git-send-email 2.25.0",
        "In-Reply-To": "<20200224193601.1040770-1-niklas.soderlund@ragnatech.se>",
        "References": "<20200224193601.1040770-1-niklas.soderlund@ragnatech.se>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 2/4] test: Extract BufferSource class\n\tout of camera tests to libtest",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "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": "Mon, 24 Feb 2020 19:36:27 -0000"
    },
    "content": "The BufferSource class can be used by other tests other then the camera\nbuffer importer test, move it to libtest. The only changes to\nBufferSource is for it to be allowed to be split in a header and source\nfile.\n\nThis change makes it necessary for libtest to have access to internal\nlibcamera headers. As the internal headers already are accessible to all\ntest cases this do not increase the exposure of libcamera internals to\nthe test cases.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n test/camera/buffer_import.cpp  | 95 +-------------------------------\n test/libtest/buffer_source.cpp | 98 ++++++++++++++++++++++++++++++++++\n test/libtest/buffer_source.h   | 32 +++++++++++\n test/libtest/meson.build       | 11 ++--\n 4 files changed, 138 insertions(+), 98 deletions(-)\n create mode 100644 test/libtest/buffer_source.cpp\n create mode 100644 test/libtest/buffer_source.h",
    "diff": "diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\nindex 6997ea78c9f608c9..3f392cdc0732941f 100644\n--- a/test/camera/buffer_import.cpp\n+++ b/test/camera/buffer_import.cpp\n@@ -16,6 +16,7 @@\n #include \"media_device.h\"\n #include \"v4l2_videodevice.h\"\n \n+#include \"buffer_source.h\"\n #include \"camera_test.h\"\n #include \"test.h\"\n \n@@ -23,100 +24,6 @@ using namespace libcamera;\n \n namespace {\n \n-/* A provider of external buffers, suitable for import by a Camera. */\n-class BufferSource\n-{\n-public:\n-\tBufferSource()\n-\t\t: video_(nullptr)\n-\t{\n-\t}\n-\n-\t~BufferSource()\n-\t{\n-\t\tif (video_) {\n-\t\t\tvideo_->releaseBuffers();\n-\t\t\tvideo_->close();\n-\t\t}\n-\n-\t\tdelete video_;\n-\t\tvideo_ = nullptr;\n-\n-\t\tif (media_)\n-\t\t\tmedia_->release();\n-\t}\n-\n-\tint allocate(const StreamConfiguration &config)\n-\t{\n-\t\t/* Locate and open the video device. */\n-\t\tstd::string videoDeviceName = \"vivid-000-vid-out\";\n-\n-\t\tstd::unique_ptr<DeviceEnumerator> enumerator =\n-\t\t\tDeviceEnumerator::create();\n-\t\tif (!enumerator) {\n-\t\t\tstd::cout << \"Failed to create device enumerator\" << std::endl;\n-\t\t\treturn TestFail;\n-\t\t}\n-\n-\t\tif (enumerator->enumerate()) {\n-\t\t\tstd::cout << \"Failed to enumerate media devices\" << std::endl;\n-\t\t\treturn TestFail;\n-\t\t}\n-\n-\t\tDeviceMatch dm(\"vivid\");\n-\t\tdm.add(videoDeviceName);\n-\n-\t\tmedia_ = enumerator->search(dm);\n-\t\tif (!media_) {\n-\t\t\tstd::cout << \"No vivid output device available\" << std::endl;\n-\t\t\treturn TestSkip;\n-\t\t}\n-\n-\t\tvideo_ = V4L2VideoDevice::fromEntityName(media_.get(), videoDeviceName);\n-\t\tif (!video_) {\n-\t\t\tstd::cout << \"Failed to get video device from entity \"\n-\t\t\t\t  << videoDeviceName << std::endl;\n-\t\t\treturn TestFail;\n-\t\t}\n-\n-\t\tif (video_->open()) {\n-\t\t\tstd::cout << \"Unable to open \" << videoDeviceName << std::endl;\n-\t\t\treturn TestFail;\n-\t\t}\n-\n-\t\t/* Configure the format. */\n-\t\tV4L2DeviceFormat format;\n-\t\tif (video_->getFormat(&format)) {\n-\t\t\tstd::cout << \"Failed to get format on output device\" << std::endl;\n-\t\t\treturn TestFail;\n-\t\t}\n-\n-\t\tformat.size = config.size;\n-\t\tformat.fourcc = V4L2VideoDevice::toV4L2Fourcc(config.pixelFormat, false);\n-\t\tif (video_->setFormat(&format)) {\n-\t\t\tstd::cout << \"Failed to set format on output device\" << std::endl;\n-\t\t\treturn TestFail;\n-\t\t}\n-\n-\t\tif (video_->exportBuffers(config.bufferCount, &buffers_) < 0) {\n-\t\t\tstd::cout << \"Failed to export buffers\" << std::endl;\n-\t\t\treturn TestFail;\n-\t\t}\n-\n-\t\treturn TestPass;\n-\t}\n-\n-\tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers()\n-\t{\n-\t\treturn buffers_;\n-\t}\n-\n-private:\n-\tstd::shared_ptr<MediaDevice> media_;\n-\tV4L2VideoDevice *video_;\n-\tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n-};\n-\n class BufferImportTest : public CameraTest, public Test\n {\n public:\ndiff --git a/test/libtest/buffer_source.cpp b/test/libtest/buffer_source.cpp\nnew file mode 100644\nindex 0000000000000000..066049d342a491f0\n--- /dev/null\n+++ b/test/libtest/buffer_source.cpp\n@@ -0,0 +1,98 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * A provider of external buffers, suitable for use in tests.\n+ */\n+\n+#include \"buffer_source.h\"\n+\n+#include <iostream>\n+\n+#include \"device_enumerator.h\"\n+\n+#include \"test.h\"\n+\n+BufferSource::BufferSource()\n+\t: video_(nullptr)\n+{\n+}\n+\n+BufferSource::~BufferSource()\n+{\n+\tif (video_) {\n+\t\tvideo_->releaseBuffers();\n+\t\tvideo_->close();\n+\t}\n+\n+\tdelete video_;\n+\tvideo_ = nullptr;\n+\n+\tif (media_)\n+\t\tmedia_->release();\n+}\n+\n+int BufferSource::allocate(const StreamConfiguration &config)\n+{\n+\t/* Locate and open the video device. */\n+\tstd::string videoDeviceName = \"vivid-000-vid-out\";\n+\n+\tstd::unique_ptr<DeviceEnumerator> enumerator =\n+\t\tDeviceEnumerator::create();\n+\tif (!enumerator) {\n+\t\tstd::cout << \"Failed to create device enumerator\" << std::endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tif (enumerator->enumerate()) {\n+\t\tstd::cout << \"Failed to enumerate media devices\" << std::endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tDeviceMatch dm(\"vivid\");\n+\tdm.add(videoDeviceName);\n+\n+\tmedia_ = enumerator->search(dm);\n+\tif (!media_) {\n+\t\tstd::cout << \"No vivid output device available\" << std::endl;\n+\t\treturn TestSkip;\n+\t}\n+\n+\tvideo_ = V4L2VideoDevice::fromEntityName(media_.get(), videoDeviceName);\n+\tif (!video_) {\n+\t\tstd::cout << \"Failed to get video device from entity \"\n+\t\t\t  << videoDeviceName << std::endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tif (video_->open()) {\n+\t\tstd::cout << \"Unable to open \" << videoDeviceName << std::endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\t/* Configure the format. */\n+\tV4L2DeviceFormat format;\n+\tif (video_->getFormat(&format)) {\n+\t\tstd::cout << \"Failed to get format on output device\" << std::endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tformat.size = config.size;\n+\tformat.fourcc = V4L2VideoDevice::toV4L2Fourcc(config.pixelFormat, false);\n+\tif (video_->setFormat(&format)) {\n+\t\tstd::cout << \"Failed to set format on output device\" << std::endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tif (video_->exportBuffers(config.bufferCount, &buffers_) < 0) {\n+\t\tstd::cout << \"Failed to export buffers\" << std::endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\treturn TestPass;\n+}\n+\n+const std::vector<std::unique_ptr<FrameBuffer>> &BufferSource::buffers()\n+{\n+\treturn buffers_;\n+}\ndiff --git a/test/libtest/buffer_source.h b/test/libtest/buffer_source.h\nnew file mode 100644\nindex 0000000000000000..2d8fc5acf6d78771\n--- /dev/null\n+++ b/test/libtest/buffer_source.h\n@@ -0,0 +1,32 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * buffer_source.h - libcamera camera test helper to create FrameBuffers\n+ */\n+#ifndef __LIBCAMERA_BUFFER_SOURCE_TEST_H__\n+#define __LIBCAMERA_BUFFER_SOURCE_TEST_H__\n+\n+#include <libcamera/libcamera.h>\n+\n+#include \"media_device.h\"\n+#include \"v4l2_videodevice.h\"\n+\n+using namespace libcamera;\n+\n+class BufferSource\n+{\n+public:\n+\tBufferSource();\n+\t~BufferSource();\n+\n+\tint allocate(const StreamConfiguration &config);\n+\tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers();\n+\n+private:\n+\tstd::shared_ptr<MediaDevice> media_;\n+\tV4L2VideoDevice *video_;\n+\tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n+};\n+\n+#endif /* __LIBCAMERA_BUFFER_SOURCE_TEST_H__ */\ndiff --git a/test/libtest/meson.build b/test/libtest/meson.build\nindex 3e798ef3810e9b0d..33565e0eb3b66d6a 100644\n--- a/test/libtest/meson.build\n+++ b/test/libtest/meson.build\n@@ -1,14 +1,11 @@\n libtest_sources = files([\n+    'buffer_source.cpp',\n     'camera_test.cpp',\n     'test.cpp',\n ])\n \n-libtest = static_library('libtest', libtest_sources,\n-                         dependencies : libcamera_dep)\n-\n libtest_includes = include_directories('.')\n \n-test_libraries = [libtest]\n \n test_includes_public = [\n     libtest_includes,\n@@ -18,3 +15,9 @@ test_includes_internal = [\n     test_includes_public,\n     libcamera_internal_includes,\n ]\n+\n+libtest = static_library('libtest', libtest_sources,\n+                         dependencies : libcamera_dep,\n+                         include_directories : test_includes_internal)\n+\n+test_libraries = [libtest]\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "2/4"
    ]
}