[{"id":27487,"web_url":"https://patchwork.libcamera.org/comment/27487/","msgid":"<48fcd298038eac84f9b909e3c2de466144682b0e.camel@collabora.com>","date":"2023-07-05T15:09:18","subject":"Re: [libcamera-devel] [PATCH v2] tests: gstreamer: Test cameras'\n\tenumeration from GstDeviceProvider","submitter":{"id":31,"url":"https://patchwork.libcamera.org/api/people/31/","name":"Nicolas Dufresne","email":"nicolas.dufresne@collabora.com"},"content":"Thanks for the fixes.\n\nLe mardi 04 juillet 2023 à 23:23 +0200, Umang Jain a écrit :\n> Test the enumeration of the cameras through GstDeviceProvider against\n> the libcamera camera manager.\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n\nReviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\n> ---\n> Changes in v2:\n> - Split out to dedicated device provider test\n> - Use gst_device_provider_factory_get_by_name() to find\n>   libcameraprovider\n> - Use \"camera-name\" to compare camera ids with camera-manager\n>   instead of gst_device_get_display_name()\n> ---\n>  .../gstreamer_device_provider_test.cpp        | 77 +++++++++++++++++++\n>  test/gstreamer/meson.build                    |  1 +\n>  2 files changed, 78 insertions(+)\n>  create mode 100644 test/gstreamer/gstreamer_device_provider_test.cpp\n> \n> diff --git a/test/gstreamer/gstreamer_device_provider_test.cpp b/test/gstreamer/gstreamer_device_provider_test.cpp\n> new file mode 100644\n> index 00000000..69e110c7\n> --- /dev/null\n> +++ b/test/gstreamer/gstreamer_device_provider_test.cpp\n> @@ -0,0 +1,77 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright 2023 Umang Jain <umang.jain@ideasonboard.com>\n> + *\n> + * gstreamer_single_stream_test.cpp - GStreamer single stream capture test\n> + */\n> +\n> +#include <vector>\n> +\n> +#include <libcamera/libcamera.h>\n> +#include <gst/gst.h>\n> +\n> +#include \"gstreamer_test.h\"\n> +#include \"test.h\"\n> +\n> +using namespace std;\n> +\n> +class GstreamerDeviceProviderTest : public GstreamerTest, public Test\n> +{\n> +public:\n> +\tGstreamerDeviceProviderTest()\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\treturn TestPass;\n> +\t}\n> +\n> +\tint run() override\n> +\t{\n> +\t\tg_autoptr(GstDeviceProvider) provider;\n> +\t\tGList *devices, *l;\n> +\t\tstd::vector<std::string> cameraNames;\n> +\t\tstd::unique_ptr<libcamera::CameraManager> cm\n> +\t\t\t= std::make_unique<libcamera::CameraManager>();\n> +\n> +\t\tcm->start();\n> +\t\tfor (auto &camera : cm->cameras())\n> +\t\t\tcameraNames.push_back(camera->id());\n> +\t\tcm->stop();\n> +\t\tcm.reset();\n> +\n> +\t\tprovider = gst_device_provider_factory_get_by_name(\"libcameraprovider\");\n> +\t\tdevices = gst_device_provider_get_devices(provider);\n> +\n> +\t\tfor (l = devices; l != NULL; l = g_list_next(l)) {\n> +\t\t\tGstDevice *device = GST_DEVICE(l->data);\n> +\t\t\tg_autofree gchar *gst_name;\n> +\t\t\tbool matched = false;\n> +\n> +\t\t\tg_autoptr(GstElement) element = gst_device_create_element(device, NULL);\n> +\t\t\tg_object_get(element, \"camera-name\", &gst_name, NULL);\n> +\n> +\t\t\tfor (auto name : cameraNames) {\n> +\t\t\t\tif (strcmp(name.c_str(), gst_name) == 0) {\n> +\t\t\t\t\tmatched = true;\n> +\t\t\t\t\tbreak;\n> +\t\t\t\t}\n> +\t\t\t}\n> +\n> +\t\t\tif (!matched)\n> +\t\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tg_list_free_full(devices, (GDestroyNotify)gst_object_unref);\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +};\n> +\n> +TEST_REGISTER(GstreamerDeviceProviderTest)\n> diff --git a/test/gstreamer/meson.build b/test/gstreamer/meson.build\n> index 74572586..0904ee0d 100644\n> --- a/test/gstreamer/meson.build\n> +++ b/test/gstreamer/meson.build\n> @@ -7,6 +7,7 @@ endif\n>  gstreamer_tests = [\n>      {'name': 'single_stream_test', 'sources': ['gstreamer_single_stream_test.cpp']},\n>      {'name': 'multi_stream_test', 'sources': ['gstreamer_multi_stream_test.cpp']},\n> +    {'name': 'device_provider_test', 'sources': ['gstreamer_device_provider_test.cpp']},\n>  ]\n>  gstreamer_dep = dependency('gstreamer-1.0', required: true)\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 39B99BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jul 2023 15:09:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6C963628C0;\n\tWed,  5 Jul 2023 17:09:30 +0200 (CEST)","from madras.collabora.co.uk (madras.collabora.co.uk\n\t[46.235.227.172])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6F6BC61E37\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jul 2023 17:09:29 +0200 (CEST)","from nicolas-tpx395.localdomain (unknown\n\t[IPv6:2606:6d00:10:88d9::7a9])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (4096 bits)\n\tserver-digest SHA256)\n\t(No client certificate requested) (Authenticated sender: nicolas)\n\tby madras.collabora.co.uk (Postfix) with ESMTPSA id 86E3E66020F5;\n\tWed,  5 Jul 2023 16:09:28 +0100 (BST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1688569770;\n\tbh=O87yWv5NK/JGtiZXmsY3C+5mK6KWJ/fUM8dMcn9n/Mw=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=mg8QkL/7mIwata4Yailc67HXP4KBmIJ0IP/b5BKc0/lyo8RFgHv1btCvAHu45otUN\n\thw48f1gejLd82DK5swPgnwcSeVivnbBSZPZMcsueykqFinMyOPyz0EG2gHJAlblS++\n\tzv62RO4y+WOrVOMFtnxyxjalL5qwgGdfDMz2NeRmzm1ZaeQ0b6pRC7YODDVZc5NGI7\n\t4zTGnJNJWI9i9raHyY0LAQYClaWqxmpTQ3k9sTyhw5+Qkrp8r6aZ0kdvb//CdlBjEh\n\t3tCcU6zFnbJgbveJkLUQX445mBd5+tQktrcK45WLNKTcaukl67u1geRh1ZfS2E1Dl2\n\twImuSt+u7vRNw==","v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com;\n\ts=mail; t=1688569769;\n\tbh=O87yWv5NK/JGtiZXmsY3C+5mK6KWJ/fUM8dMcn9n/Mw=;\n\th=Subject:From:To:Cc:Date:In-Reply-To:References:From;\n\tb=fJOakdA46C+++AZk6mD6VKXO2RAwy3f7rwdLZn2d9mNzmgNnT6p8wg9XOyzS06I6f\n\tI8iWX9jUzqmiyg3YncYXmDkjNJrC/B7N3UX5I2Cg70XVlOAG+tzXmP+S8FYtZ1iPA2\n\tF+WVpb5wkg835OdSurKgBJi9HGFCfvDmG575a90F3xPuFpsT7lM6K/G6Z54Diy9oXd\n\t293MIQ8mrZGwDpovV6RhZRI5MA/Q6BBkMkPCylMbE7aELQTsF3ZN8f0hmN6z9Q7B+V\n\tyZYbYsoQ5RtWiQjkZYPey2PKDFmWi3siTMGtsihS9l4+qR3HYdAsta3ph1H5ACtW2H\n\tByG7/1Lf8dN7A=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=collabora.com\n\theader.i=@collabora.com\n\theader.b=\"fJOakdA4\"; dkim-atps=neutral","Message-ID":"<48fcd298038eac84f9b909e3c2de466144682b0e.camel@collabora.com>","To":"Umang Jain <umang.jain@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 05 Jul 2023 11:09:18 -0400","In-Reply-To":"<20230704212343.78465-1-umang.jain@ideasonboard.com>","References":"<20230704212343.78465-1-umang.jain@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","User-Agent":"Evolution 3.48.3 (3.48.3-1.fc38) ","MIME-Version":"1.0","Subject":"Re: [libcamera-devel] [PATCH v2] tests: gstreamer: Test cameras'\n\tenumeration from GstDeviceProvider","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>","From":"Nicolas Dufresne via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Nicolas Dufresne <nicolas.dufresne@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]