{"id":13912,"url":"https://patchwork.libcamera.org/api/patches/13912/?format=json","web_url":"https://patchwork.libcamera.org/patch/13912/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20210923134653.1612991-1-vedantparanjape160201@gmail.com>","date":"2021-09-23T13:46:53","name":"[libcamera-devel,v2] test: gstreamer: Add a test for gstreamer multi stream","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"fb1bc40b14acd12cc09aa1b676cf97e2ee14e8cf","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/people/85/?format=json","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13912/mbox/","series":[{"id":2555,"url":"https://patchwork.libcamera.org/api/series/2555/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2555","date":"2021-09-23T13:46:53","name":"[libcamera-devel,v2] test: gstreamer: Add a test for gstreamer multi stream","version":2,"mbox":"https://patchwork.libcamera.org/series/2555/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13912/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13912/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 9B7EABDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Sep 2021 13:47:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 173146918E;\n\tThu, 23 Sep 2021 15:47:11 +0200 (CEST)","from mail-pg1-x529.google.com (mail-pg1-x529.google.com\n\t[IPv6:2607:f8b0:4864:20::529])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D70E769189\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Sep 2021 15:47:08 +0200 (CEST)","by mail-pg1-x529.google.com with SMTP id f129so6402784pgc.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Sep 2021 06:47:08 -0700 (PDT)","from localhost.localdomain ([1.186.166.66])\n\tby smtp.googlemail.com with ESMTPSA id\n\tt8sm9146195pjt.39.2021.09.23.06.47.05\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 23 Sep 2021 06:47:06 -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=\"kQNvqKPV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=tH7Gi4/2jtRGwGaPA5Qv1ukDDDjAu54TslzbkGJmDCc=;\n\tb=kQNvqKPVXz5xh5ZRJGUB54b8l37GbpnJuU8Q6Vwi4FTyyBjVFKoJWckbtqarY/nsGd\n\tLN3V5BiF1mlptV/u3D2z9cD1QMMCxM04YaJpdaWVBYU0mNHBAwYxf/tiooqNV3oHgqZD\n\t7pd50fhz1jRY244AvhzPYiRv1eaD0mKxb7h9bCwhzZ/KEXa1Sr+USCvH+n1QXSvwqLD+\n\tQHmKTjDYkqwci3dcJsI/vNu2NOFYyECJQa2FY+JSyq4cyuHEx38oYUjMXXvKvgttjQV+\n\toK8RO65X4LyCqekdxveCb21l6n4I6PMXck2MiVgCdGHLsyCRXNU1GIuA4T6JarOqp8dz\n\tdsQQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=tH7Gi4/2jtRGwGaPA5Qv1ukDDDjAu54TslzbkGJmDCc=;\n\tb=MQkJsDh3c5p2yfMF27JaNSO9ZrC2QtBo8QyLKehqlDFPj+iLp0RyosZQkAhs1QyX/R\n\tltqMWrdab0Ux657mgGbOQZyBIi73ALEDbbvBA9UMFtUyIVO32h7Q1Dw/YSo3WB5/w4Pq\n\tcgwvS/AmV6ZRgW6gVldVsRGBa1Lve9bvdWBTwgFVdEJQ9Agb3LdG9VmcXK6Aexybr9da\n\tc2WSx8j4fJeUgCq+mGCCMHi66Kh0DYElCBTEpMNXg3rzv8YawvDJJ0jGSffzhY8j6an3\n\tGqZrr0giKQu1rF2kDwE/QUoQuH7mmq80s39/qC/nPyKj1MFt33RxOC0hQlV/zPIU2p5k\n\tV0aw==","X-Gm-Message-State":"AOAM530eCuLmWOFNkrz2QUDo72HnpYH8dypsqURWeDanbbGa2w5QbaSD\n\taNCM0m4w9TZ1j8rxMNsUkMjviJF15FqVMgmK","X-Google-Smtp-Source":"ABdhPJyMUSoBr+ZJgZzyuFccuavPzb140F5mZe8UsqK/02B8g9fO1uhvgPdf7pRzhwXVrtMuhNe1sA==","X-Received":"by 2002:a63:4301:: with SMTP id q1mr1851611pga.430.1632404826906;\n\tThu, 23 Sep 2021 06:47:06 -0700 (PDT)","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 23 Sep 2021 19:16:53 +0530","Message-Id":"<20210923134653.1612991-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":"Nicolas Dufresne <nicolas.dufresne@collabora.com>,\n\tVedant 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\nTest will run only on devices that support multistream output, i.e.,\ndevices that use IPU3 and raspberrypi pipeline. This was tested on\na Raspberry Pi 4B+.\n\nSigned-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\nReviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n---\n .../gstreamer/gstreamer_multi_stream_test.cpp | 121 ++++++++++++++++++\n test/gstreamer/meson.build                    |   1 +\n 2 files changed, 122 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 000000000000..5df1dd40388a\n--- /dev/null\n+++ b/test/gstreamer/gstreamer_multi_stream_test.cpp\n@@ -0,0 +1,121 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2021, Vedant Paranjape\n+ *\n+ * gstreamer_multi_stream_test.cpp - GStreamer multi 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 \"gstreamer_test.h\"\n+#include \"test.h\"\n+\n+using namespace std;\n+\n+class GstreamerMultiStreamTest : public GstreamerTest, public Test\n+{\n+public:\n+\tGstreamerMultiStreamTest()\n+\t\t: GstreamerTest()\n+\t{\n+\t}\n+\n+protected:\n+\tint init() override\n+\t{\n+\t\tif (status_ != TestPass)\n+\t\t\treturn status_;\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 &camera : cm.cameras()) {\n+\t\t\tif (camera->streams().size() > 1) {\n+\t\t\t\tcameraName = camera->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\tconst gchar *streamDescription = \"queue ! fakesink\";\n+\t\tg_autoptr(GError) error0 = NULL;\n+\t\tg_autoptr(GError) error1 = NULL;\n+\t\tstream0_ = gst_parse_bin_from_description_full(streamDescription, TRUE, NULL, GST_PARSE_FLAG_FATAL_ERRORS, &error0);\n+\t\tstream1_ = gst_parse_bin_from_description_full(streamDescription, TRUE, NULL, GST_PARSE_FLAG_FATAL_ERRORS, &error1);\n+\n+\t\tif (!stream0_) {\n+\t\t\tg_printerr(\"Bin 0 could not be created (%s)\\n\", error0->message);\n+\t\t\treturn TestFail;\n+\t\t}\n+\t\tif (!stream1_) {\n+\t\t\tg_printerr(\"Bin 1 could not be created (%s)\\n\", error1->message);\n+\t\t\treturn TestFail;\n+\t\t}\n+\t\tg_object_ref_sink(stream0_);\n+\t\tg_object_ref_sink(stream1_);\n+\n+\t\tif (createPipeline() != TestPass)\n+\t\t\treturn TestFail;\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tint run() override\n+\t{\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_,\n+\t\t\t\t\t\t\tstream0_, stream1_, NULL);\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+\n+\t\t{\n+\t\t\tg_autoptr(GstPad) queue0_sink_pad = gst_element_get_static_pad(stream0_, \"sink\");\n+\t\t\tg_autoptr(GstPad) queue1_sink_pad = gst_element_get_static_pad(stream1_, \"sink\");\n+\n+\t\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\t\tg_printerr(\"Pads could not be linked.\\n\");\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (startPipeline() != TestPass)\n+\t\t\treturn TestFail;\n+\n+\t\tif (processEvent() != TestPass)\n+\t\t\treturn TestFail;\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tvoid cleanup() override\n+\t{\n+\t\tg_clear_object(&stream0_);\n+\t\tg_clear_object(&stream1_);\n+\t}\n+private:\n+\tstd::string cameraName;\n+\tGstElement *stream0_;\n+\tGstElement *stream1_;\n+};\n+\n+TEST_REGISTER(GstreamerMultiStreamTest)\ndiff --git a/test/gstreamer/meson.build b/test/gstreamer/meson.build\nindex aca53b920365..13652e87d05c 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"]}