[{"id":19817,"web_url":"https://patchwork.libcamera.org/comment/19817/","msgid":"<f8541e57e8cc9d231641268fdc50d7c0304b919d.camel@collabora.com>","date":"2021-09-23T13:07:56","subject":"Re: [libcamera-devel] [PATCH v1] test: gstreamer: Add a test for\n\tgstreamer multi stream","submitter":{"id":31,"url":"https://patchwork.libcamera.org/api/people/31/","name":"Nicolas Dufresne","email":"nicolas.dufresne@collabora.com"},"content":"Le jeudi 23 septembre 2021 à 16:35 +0530, Vedant Paranjape a écrit :\n> This patch adds a test to test if multi stream using libcamera's\n> gstreamer element works.\n> \n> Test will run only on devices that support multistream output, i.e.,\n> devices that use IPU3 and raspberrypi pipeline. This was tested on\n> a Raspberry Pi 4B+.\n> \n> Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> ---\n> \n> I am unable to run Valgrind on my RPI4B+, please check for memory\n> leaks on RPI4B+ as well. I used the following steps to test on amd64\n> system using the suppression files.\n> \n> <snip>\n> cd libcamera\n> wget https://cgit.freedesktop.org/gstreamer/common/plain/gst.supp -P /tmp\n> ninja -C build test\n> valgrind --leak-check=full --suppressions=/usr/share/glib-2.0/valgrind/glib.supp --suppressions=/tmp/gst.supp ./build/test/gstreamer/single_stream_test\n> valgrind --leak-check=full --suppressions=/usr/share/glib-2.0/valgrind/glib.supp --suppressions=/tmp/gst.supp ./build/test/gstreamer/multi_stream_test\n> <snip>\n> \n> Also please test this test on IPU3 enabled devices too, as I don't have\n> access to the same.\n> \n> ---\n>  .../gstreamer/gstreamer_multi_stream_test.cpp | 118 ++++++++++++++++++\n>  test/gstreamer/meson.build                    |   1 +\n>  2 files changed, 119 insertions(+)\n>  create mode 100644 test/gstreamer/gstreamer_multi_stream_test.cpp\n> \n> diff --git a/test/gstreamer/gstreamer_multi_stream_test.cpp b/test/gstreamer/gstreamer_multi_stream_test.cpp\n> new file mode 100644\n> index 000000000000..76cf5a3418a1\n> --- /dev/null\n> +++ b/test/gstreamer/gstreamer_multi_stream_test.cpp\n> @@ -0,0 +1,118 @@\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 ! videoconvert ! fakesink\";\n\nConverter could be removed, it will always passthrough.\n\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_ || !stream1_) {\n> +\t\t\tg_printerr(\"Not all bins could be created. %p.%p\\n\",\n> +\t\t\t\t\t\tstream0_, stream1_);\n\nPlease, split this in two checks, so you can dump the appropriate error message.\n\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)\n> diff --git a/test/gstreamer/meson.build b/test/gstreamer/meson.build\n> index 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\nLooks good with that minor change.\n\nReviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\n>","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 7D4A4BF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Sep 2021 13:08:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BF8E06918C;\n\tThu, 23 Sep 2021 15:08:07 +0200 (CEST)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AADE369189\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Sep 2021 15:08:06 +0200 (CEST)","from [127.0.0.1] (localhost [127.0.0.1])\n\t(Authenticated sender: nicolas) with ESMTPSA id B8C1F1F441E0"],"Message-ID":"<f8541e57e8cc9d231641268fdc50d7c0304b919d.camel@collabora.com>","From":"Nicolas Dufresne <nicolas.dufresne@collabora.com>","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>, \n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 23 Sep 2021 09:07:56 -0400","In-Reply-To":"<20210923110518.1556973-1-vedantparanjape160201@gmail.com>","References":"<20210923110518.1556973-1-vedantparanjape160201@gmail.com>","Content-Type":"text/plain; charset=\"UTF-8\"","User-Agent":"Evolution 3.40.4 (3.40.4-1.fc34) ","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v1] 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]