Show a patch.

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

{
    "id": 13564,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/13564/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13564/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20210829113104.526991-1-vedantparanjape160201@gmail.com>",
    "date": "2021-08-29T11:31:04",
    "name": "[libcamera-devel,v2] test: gstreamer: Add a test for gstreamer multi stream",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "4e7973e9025ba7cc5e813fdd100f2179ef3a192b",
    "submitter": {
        "id": 85,
        "url": "https://patchwork.libcamera.org/api/1.1/people/85/?format=api",
        "name": "Vedant Paranjape",
        "email": "vedantparanjape160201@gmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13564/mbox/",
    "series": [
        {
            "id": 2418,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2418/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2418",
            "date": "2021-08-29T11:31:04",
            "name": "[libcamera-devel,v2] test: gstreamer: Add a test for gstreamer multi stream",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2418/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13564/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13564/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7EF86BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 29 Aug 2021 11:31:19 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 32CC16916A;\n\tSun, 29 Aug 2021 13:31:19 +0200 (CEST)",
            "from mail-pg1-x531.google.com (mail-pg1-x531.google.com\n\t[IPv6:2607:f8b0:4864:20::531])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4203968891\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 29 Aug 2021 13:31:18 +0200 (CEST)",
            "by mail-pg1-x531.google.com with SMTP id g184so10542882pgc.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 29 Aug 2021 04:31:18 -0700 (PDT)",
            "from localhost.localdomain ([1.186.166.201])\n\tby smtp.googlemail.com with ESMTPSA id\n\tp11sm1515617pfw.203.2021.08.29.04.31.14\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 29 Aug 2021 04:31:15 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"tc4AvzJ7\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=Am55ocytg6tbTJGHmSHELvf7ENqP/6U0oK2Wi1yFFwI=;\n\tb=tc4AvzJ72NvDpIU0TI5kYWdL8VJ92mNKQZfJYGCsjUMWxONEYvZSyZp7IZbt68FS29\n\tIA3SAqI1tYp6E3NYsNsmmrzE2/G6kGxoK+P/Kwveo7syB/V/rF0+oCbYUAx6ow5v2LDQ\n\t21+7jSnG1H5mEJJg9Gi6or7qgHdQOHNp04AwnbKO+BclTyDx2Mfm/numt0o1O9B8pOI6\n\tSnYkmU9IeYmDOOCeSrVc5l4s586S8uIKFwUlKwcfwtmE3rjwCNdTOIlfJkHICznAFvot\n\tol2GOTq1VhBmY7//oQkdUkmOJPTCSDFEdCG8e8hBX82dnjsmB1+OCLRN+Qsy2HDecNaI\n\tFhMg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=Am55ocytg6tbTJGHmSHELvf7ENqP/6U0oK2Wi1yFFwI=;\n\tb=N0PtrJn6AGrkRWIeeSMn4L58R6JX7W+BmoX1eIUgkHKWgolzufof7sUh175i1rqgzR\n\tpNpjLvJp7d9vva5qXGKgu4V8jZ0ve9vcEr8ioEM81wkCdtdL7+eimTDSJq6UJIP/dLwx\n\ta13lalHbHGs9uj6FR7+r0fOQAUCcc8hnn6KbyTpVeItArLyd5j4ql01TPYagdassIITh\n\tj92gi+CN7Bipv88G75nLYHglCeKe0UyZREnOnHGpp4hUmI9FyLlxosR/6kaUp7ipjOrv\n\tOWIMPlIKdoOrF/7ukd7h0YhHVCygHZ/VohVQxHC7LUTNSq47u+IyeUJwFEgUGzIxj5Ib\n\tsc3w==",
        "X-Gm-Message-State": "AOAM533dvu2XyHtsh/Pfa132GnxX7+NxJqS+qA2+/grpkKufNw/tHNVA\n\ter2a8LQ3NRTw6g51vcVjycJr2YnJx8pSlw==",
        "X-Google-Smtp-Source": "ABdhPJzT5mrgWD2J4fFcP+0c1nf9JL8hDl93bDpZrULLTSsQ583zzZIUjRv/cvIdMYaddpDMXAKhsA==",
        "X-Received": "by 2002:a63:4b5a:: with SMTP id\n\tk26mr16497216pgl.241.1630236676495; \n\tSun, 29 Aug 2021 04:31:16 -0700 (PDT)",
        "From": "Vedant Paranjape <vedantparanjape160201@gmail.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun, 29 Aug 2021 17:01:04 +0530",
        "Message-Id": "<20210829113104.526991-1-vedantparanjape160201@gmail.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2] test: gstreamer: Add a test for\n\tgstreamer multi stream",
        "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>",
        "Cc": "Vedant Paranjape <vedantparanjape160201@gmail.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "This patch adds a test to test if multi stream using libcamera's\ngstreamer element works.\n\nWe need to work around one issue with ASan when enabled in the\nbuild:\n\n- glib has a known leak at initialization time. This is covered by the\n  suppression file shipped with glib, but it's not clear how to use it\n  automatically. For now, disable leak detection to avoid test failures.\n\nSigned-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n---\n .../gstreamer/gstreamer_multi_stream_test.cpp | 238 ++++++++++++++++++\n test/gstreamer/meson.build                    |   1 +\n 2 files changed, 239 insertions(+)\n create mode 100644 test/gstreamer/gstreamer_multi_stream_test.cpp",
    "diff": "diff --git a/test/gstreamer/gstreamer_multi_stream_test.cpp b/test/gstreamer/gstreamer_multi_stream_test.cpp\nnew file mode 100644\nindex 00000000..4f54b385\n--- /dev/null\n+++ b/test/gstreamer/gstreamer_multi_stream_test.cpp\n@@ -0,0 +1,238 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2021, Vedant Paranjape\n+ *\n+ * gstreamer_single_stream_test.cpp - GStreamer single stream capture test\n+ */\n+\n+#include <iostream>\n+#include <unistd.h>\n+\n+#include <libcamera/base/utils.h>\n+\n+#include <libcamera/libcamera.h>\n+\n+#include \"libcamera/internal/source_paths.h\"\n+\n+#include <gst/gst.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+\n+extern \"C\" {\n+const char *__asan_default_options()\n+{\n+\t/*\n+\t * Disable leak detection due to a known global variable initialization\n+\t * leak in glib's g_quark_init(). This should ideally be handled by\n+\t * using a suppression file instead of disabling leak detection.\n+\t */\n+\treturn \"detect_leaks=false\";\n+}\n+}\n+\n+class GstreamerSingleStreamTest : public Test\n+{\n+protected:\n+\tint init() override\n+\t{\n+\t\t/*\n+\t\t * GStreamer by default spawns a process to run the\n+\t\t * gst-plugin-scanner helper. If libcamera is compiled with ASan\n+\t\t * enabled, and as GStreamer is most likely not, this causes the\n+\t\t * ASan link order check to fail when gst-plugin-scanner\n+\t\t * dlopen()s the plugin as many libraries will have already been\n+\t\t * loaded by then. Fix this issue by disabling spawning of a\n+\t\t * child helper process when scanning the build directory for\n+\t\t * plugins.\n+\t\t */\n+\t\tgst_registry_fork_set_enabled(false);\n+\n+\t\t/* Initialize GStreamer */\n+\t\tg_autoptr(GError) errInit = NULL;\n+\t\tif (!gst_init_check(nullptr, nullptr, &errInit)) {\n+\t\t\tg_printerr(\"Could not initialize GStreamer: %s\\n\",\n+\t\t\t\t   errInit ? errInit->message : \"unknown error\");\n+\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Remove the system libcamera plugin, if any, and add the\n+\t\t * plugin from the build directory.\n+\t\t */\n+\t\tGstRegistry *registry = gst_registry_get();\n+\t\tGstPlugin *plugin = gst_registry_lookup(registry, \"libgstlibcamera.so\");\n+\t\tif (plugin) {\n+\t\t\tgst_registry_remove_plugin(registry, plugin);\n+\t\t\tgst_object_unref(plugin);\n+\t\t}\n+\n+\t\tstd::string path = libcamera::utils::libcameraBuildPath()\n+\t\t\t\t + \"src/gstreamer\";\n+\t\tif (!gst_registry_scan_path(registry, path.c_str())) {\n+\t\t\tg_printerr(\"Failed to add plugin to registry\\n\");\n+\t\t\tgst_deinit();\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Check if platform support multistream output */\n+\t\tlibcamera::CameraManager cm;\n+\t\tcm.start();\n+\t\tbool cameraFound = false;\n+\t\tfor (auto &i : cm.cameras()) {\n+\t\t\tif (i->streams().size() > 1) {\n+\t\t\t\tcameraName = i->id();\n+\t\t\t\tcameraFound = true;\n+\t\t\t\tcm.stop();\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (!cameraFound) {\n+\t\t\tcm.stop();\n+\t\t\treturn TestSkip;\n+\t\t}\n+\n+\t\t/* Create the elements */\n+\t\tlibcameraSrc_ = gst_element_factory_make(\"libcamerasrc\", \"libcamera\");\n+\t\tconvert0_ = gst_element_factory_make(\"videoconvert\", \"convert0\");\n+\t\tconvert1_ = gst_element_factory_make(\"videoconvert\", \"convert1\");\n+\t\tsink0_ = gst_element_factory_make(\"fakesink\", \"sink0\");\n+\t\tsink1_ = gst_element_factory_make(\"fakesink\", \"sink1\");\n+\t\tqueue0_ = gst_element_factory_make(\"queue\", \"camera_queue0\");\n+\t\tqueue1_ = gst_element_factory_make(\"queue\", \"camera_queue1\");\n+\n+\t\t/* Create the empty pipeline_ */\n+\t\tpipeline_ = gst_pipeline_new(\"test-pipeline\");\n+\n+\t\tif (!pipeline_ || !convert0_ || !convert1_ || !sink0_ ||\n+\t\t\t!sink1_ || !queue0_ || !queue1_ || !libcameraSrc_) {\n+\t\t\tg_printerr(\"Not all elements could be created. %p.%p.%p.%p.%p.%p.%p.%p\\n\",\n+\t\t\t\t\t\tpipeline_, convert0_, convert1_, sink0_,\n+\t\t\t\t\t\tsink1_, queue0_, queue1_, libcameraSrc_);\n+\t\t\tif (pipeline_)\n+\t\t\t\tgst_object_unref(pipeline_);\n+\t\t\tif (convert0_)\n+\t\t\t\tgst_object_unref(convert0_);\n+\t\t\tif (convert1_)\n+\t\t\t\tgst_object_unref(convert1_);\n+\t\t\tif (sink0_)\n+\t\t\t\tgst_object_unref(sink0_);\n+\t\t\tif (sink1_)\n+\t\t\t\tgst_object_unref(sink1_);\n+\t\t\tif (queue0_)\n+\t\t\t\tgst_object_unref(queue0_);\n+\t\t\tif (queue1_)\n+\t\t\t\tgst_object_unref(queue1_);\n+\t\t\tif (libcameraSrc_)\n+\t\t\t\tgst_object_unref(libcameraSrc_);\n+\t\t\tgst_deinit();\n+\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tvoid cleanup() override\n+\t{\n+\t\tgst_object_unref(pipeline_);\n+\t\tgst_deinit();\n+\t}\n+\n+\tint run() override\n+\t{\n+\t\tGstStateChangeReturn ret;\n+\n+\t\tg_object_set(libcameraSrc_, \"camera-name\", cameraName.c_str(), NULL);\n+\n+\t\t/* Build the pipeline */\n+\t\tgst_bin_add_many(GST_BIN(pipeline_), libcameraSrc_, queue0_, queue1_,\n+\t\t\t\t\t\t\tconvert0_, convert1_, sink0_, sink1_, NULL);\n+\t\tif (gst_element_link_many(queue0_, convert0_, sink0_, NULL) != TRUE\n+\t\t\t\t|| gst_element_link_many(queue1_, convert1_, sink1_, NULL) != TRUE) {\n+\t\t\tg_printerr(\"Elements could not be linked.\\n\");\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tg_autoptr(GstPad) src_pad = gst_element_get_static_pad(libcameraSrc_, \"src\");\n+\t\tg_autoptr(GstPad) request_pad = gst_element_get_request_pad(libcameraSrc_, \"src_%u\");\n+\t\tGstPad *queue0_sink_pad = gst_element_get_static_pad(queue0_, \"sink\");\n+\t\tGstPad *queue1_sink_pad = gst_element_get_static_pad(queue1_, \"sink\");\n+\n+\t\tif (gst_pad_link(src_pad, queue0_sink_pad) != GST_PAD_LINK_OK\n+\t\t\t\t|| gst_pad_link(request_pad, queue1_sink_pad) != GST_PAD_LINK_OK) {\n+\t\t\tif (queue0_sink_pad)\n+\t\t\t\tgst_object_unref(queue0_sink_pad);\n+\t\t\tif (queue1_sink_pad)\n+\t\t\t\tgst_object_unref(queue1_sink_pad);\n+\t\t\tg_printerr(\"Pads could not be linked.\\n\");\n+\t\t\treturn TestFail;\n+\t\t}\n+\t\tgst_object_unref(queue0_sink_pad);\n+\t\tgst_object_unref(queue1_sink_pad);\n+\n+\t\t/* Start playing */\n+\t\tret = gst_element_set_state(pipeline_, GST_STATE_PLAYING);\n+\t\tif (ret == GST_STATE_CHANGE_FAILURE) {\n+\t\t\tg_printerr(\"Unable to set the pipeline to the playing state.\\n\");\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Wait until error or EOS or timeout after 2 seconds */\n+\t\tconstexpr GstMessageType msgType =\n+\t\t\tstatic_cast<GstMessageType>(GST_MESSAGE_ERROR | GST_MESSAGE_EOS);\n+\t\tconstexpr GstClockTime timeout = 2 * GST_SECOND;\n+\n+\t\tg_autoptr(GstBus) bus = gst_element_get_bus(pipeline_);\n+\t\tg_autoptr(GstMessage) msg = gst_bus_timed_pop_filtered(bus, timeout, msgType);\n+\n+\t\tgst_element_set_state(pipeline_, GST_STATE_NULL);\n+\n+\t\t/* Parse error message */\n+\t\tif (msg == NULL)\n+\t\t\treturn TestPass;\n+\n+\t\tswitch (GST_MESSAGE_TYPE(msg)) {\n+\t\tcase GST_MESSAGE_ERROR:\n+\t\t\tgstreamer_print_error(msg);\n+\t\t\tbreak;\n+\t\tcase GST_MESSAGE_EOS:\n+\t\t\tg_print(\"End-Of-Stream reached.\\n\");\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tg_printerr(\"Unexpected message received.\\n\");\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\treturn TestFail;\n+\t}\n+\n+private:\n+\tvoid gstreamer_print_error(GstMessage *msg)\n+\t{\n+\t\tg_autoptr(GError) err = NULL;\n+\t\tg_autofree gchar *debug_info = NULL;\n+\n+\t\tgst_message_parse_error(msg, &err, &debug_info);\n+\t\tg_printerr(\"Error received from element %s: %s\\n\",\n+\t\t\t\tGST_OBJECT_NAME(msg->src), err->message);\n+\t\tg_printerr(\"Debugging information: %s\\n\",\n+\t\t\t\tdebug_info ? debug_info : \"none\");\n+\t}\n+\n+\tstd::string cameraName;\n+\tGstElement *pipeline_;\n+\tGstElement *libcameraSrc_;\n+\tGstElement *queue0_;\n+\tGstElement *queue1_;\n+\tGstElement *convert0_;\n+\tGstElement *convert1_;\n+\tGstElement *sink0_;\n+\tGstElement *sink1_;\n+\n+};\n+\n+TEST_REGISTER(GstreamerSingleStreamTest)\ndiff --git a/test/gstreamer/meson.build b/test/gstreamer/meson.build\nindex b99aa0da..e28225b2 100644\n--- a/test/gstreamer/meson.build\n+++ b/test/gstreamer/meson.build\n@@ -6,6 +6,7 @@ endif\n \n gstreamer_tests = [\n     ['single_stream_test',   'gstreamer_single_stream_test.cpp'],\n+    ['multi_stream_test',   'gstreamer_multi_stream_test.cpp'],\n ]\n gstreamer_dep = dependency('gstreamer-1.0', required: true)\n \n",
    "prefixes": [
        "libcamera-devel",
        "v2"
    ]
}