{"id":18783,"url":"https://patchwork.libcamera.org/api/patches/18783/?format=json","web_url":"https://patchwork.libcamera.org/patch/18783/","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":"<20230704212343.78465-1-umang.jain@ideasonboard.com>","date":"2023-07-04T21:23:43","name":"[libcamera-devel,v2] tests: gstreamer: Test cameras' enumeration from GstDeviceProvider","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"0007e1b0f50ef74b3ea4965d1854c0230ff61247","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18783/mbox/","series":[{"id":3951,"url":"https://patchwork.libcamera.org/api/series/3951/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3951","date":"2023-07-04T21:23:43","name":"[libcamera-devel,v2] tests: gstreamer: Test cameras' enumeration from GstDeviceProvider","version":2,"mbox":"https://patchwork.libcamera.org/series/3951/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18783/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18783/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 9FF78BE175\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  4 Jul 2023 21:23:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F04E361E38;\n\tTue,  4 Jul 2023 23:23:56 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DEAD160384\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  4 Jul 2023 23:23:54 +0200 (CEST)","from umang.jainideasonboard.com (85-160-42-71.reb.o2.cz\n\t[85.160.42.71])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 068BD8C1;\n\tTue,  4 Jul 2023 23:23:09 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1688505837;\n\tbh=ZRxtU64Lq5Z6ozMj9enwYurqidHV6K4Wt3ozvBqOMNU=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=BOb53Ld/biWu9Yr3xdFuiSgxkkOVEfrg4P1n1GOQrFhKcA+KALfSezhj0Tua7f+02\n\t5SsuZWjSF1c5U6RVzMVispYhau5uXhgAn3tkqZEla0m2lBpudwEDBjU2jJTbrs/wFB\n\tFgchtVhiQPQr7K++Ffd1lqXXf6mCmp9mkDiPubrzdAnDac8Mnf1TEHAsI9qNKJTsN7\n\tSoXN+zAv2nepkt5UgvKQF1fpiAPMPXhEOVHBvjMM4nfNXtiZG/vyc+oQTEGXYuh3vN\n\tYbdm55hCRuBEVftxgdy3ikZfNK66DsOHVcfGsFIWujVoj/XmMJm8mj64mOOp0XPZQi\n\tvGWq+EGxgYbQA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1688505790;\n\tbh=ZRxtU64Lq5Z6ozMj9enwYurqidHV6K4Wt3ozvBqOMNU=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=NzqEAEbZEmcTjWEqcn+gH2/ACauPj1Z9GWMue+uG0frAZVjCmJKRWr1wi1StGNEKx\n\tlBvoqmylwEWpnNdtpqSF+/6zZRFNBz/05Zq0QEn77YEcpuvVCorCnk5iy0CYvY8dr1\n\t4YMlfDu6cvvQXSzCA9DPjwKevt8R3jrBUVEIMSY4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"NzqEAEbZ\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  4 Jul 2023 23:23:43 +0200","Message-Id":"<20230704212343.78465-1-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.39.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[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":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Cc":"nicolas.dufresne@collabora.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Test the enumeration of the cameras through GstDeviceProvider against\nthe libcamera camera manager.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\nChanges 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","diff":"diff --git a/test/gstreamer/gstreamer_device_provider_test.cpp b/test/gstreamer/gstreamer_device_provider_test.cpp\nnew file mode 100644\nindex 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)\ndiff --git a/test/gstreamer/meson.build b/test/gstreamer/meson.build\nindex 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 \n","prefixes":["libcamera-devel","v2"]}