{"id":13270,"url":"https://patchwork.libcamera.org/api/1.1/patches/13270/?format=json","web_url":"https://patchwork.libcamera.org/patch/13270/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20210810073444.1739476-1-vedantparanjape160201@gmail.com>","date":"2021-08-10T07:34:44","name":"[libcamera-devel,v1] gstreamer: Add unit test to test single stream output","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"fdda32463d534080500aa84022304bb63f7bea67","submitter":{"id":85,"url":"https://patchwork.libcamera.org/api/1.1/people/85/?format=json","name":"Vedant Paranjape","email":"vedantparanjape160201@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13270/mbox/","series":[{"id":2326,"url":"https://patchwork.libcamera.org/api/1.1/series/2326/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2326","date":"2021-08-10T07:34:44","name":"[libcamera-devel,v1] gstreamer: Add unit test to test single stream output","version":1,"mbox":"https://patchwork.libcamera.org/series/2326/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13270/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13270/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 B9083C3240\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 10 Aug 2021 07:35:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 83820687FA;\n\tTue, 10 Aug 2021 09:35:23 +0200 (CEST)","from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com\n\t[IPv6:2607:f8b0:4864:20::102b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 276A2687DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Aug 2021 09:35:22 +0200 (CEST)","by mail-pj1-x102b.google.com with SMTP id\n\tu13-20020a17090abb0db0290177e1d9b3f7so3103674pjr.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Aug 2021 00:35:22 -0700 (PDT)","from localhost.localdomain ([1.186.167.156])\n\tby smtp.googlemail.com with ESMTPSA id\n\tr13sm25907298pgi.78.2021.08.10.00.35.18\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 10 Aug 2021 00:35:19 -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=\"Mpnct7lF\"; 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=EU+nH2IQ6yt3lCTsE23t4o2bpLB6ImUTB4GDIeKqKP8=;\n\tb=Mpnct7lFIv8RRT1Yv1TxRoqkONuQgA5JWiKNX9gRzR+hmyGOQc2en1KEoSGMRrslaO\n\tCdayFt9z6jtiNBlP2lkkapattkiP0FNF+rLiktTXHKBlnHQA4Akb6FwiWtelYKlYkxrm\n\tZ+zRNxAa2hXWJ8cNkZ7+uIAm91glIgh0j1trSwJhQuy05yNfuhC5a2OCjlBm0XvGWFnE\n\t+v+DblkQ+mUt9s123IgaacL1bN06fEVqwKM4NGlcZ1o0ZSbjJNNrSDPy2NAWv9+i6IXF\n\t67FYjdYeCuzqELjIJfa30e1KQxEOOs1bI5IAdH9fjVnJQQ+VCiEpI8H5hB6rkyafokkx\n\tUGZA==","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=EU+nH2IQ6yt3lCTsE23t4o2bpLB6ImUTB4GDIeKqKP8=;\n\tb=Ww9nNeYJ7BvdI7Pzd5hFMCv8C8jDYpiGwKIpfoSMKIjGHqu5YM8hRq7haszlbDUM0W\n\t/yJ/CjazoUsDqT/G7BsVtTEMOJo83xt9qE5wIzaBquMU1SBsnILRb3aBl8pdr2Khqcfl\n\taYvs2Fvmduu1G+09ze+lb1fWmfH19c3Hymx6kpJliRzkkmji4P2uq0IEBFuVzVk/Rgmw\n\t310+uYj6aiUpBHrCn704bOVHf4Cd+T8ofFm0Uxm/eiD6nDK0MbxkKi0CRt4MLRv2j5bm\n\tQRr9s5+L8hBa8j7r/iNLY0Tp1L/giMqIv2sZrs0nUamEX0p0AVbyhrulyUbhdWvC6s1e\n\tM70Q==","X-Gm-Message-State":"AOAM532oMHp/tgGrJBBEJ+8+BwPyiy4obgtd3IJfhlWy9zBRSqcvqi0s\n\tdnv0ZTL32mBg6604RE0ktUtzrzuwM9eVtw==","X-Google-Smtp-Source":"ABdhPJx5s4aYn+pkMTa+JU9OP1JcKO9BmLtUhZRcvoSohFxwqdSgYiGsEROAIqVHCBFl0QXojITUhw==","X-Received":"by 2002:a62:32c7:0:b029:3cd:fba0:3218 with SMTP id\n\ty190-20020a6232c70000b02903cdfba03218mr575323pfy.52.1628580920023; \n\tTue, 10 Aug 2021 00:35:20 -0700 (PDT)","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 10 Aug 2021 13:04:44 +0530","Message-Id":"<20210810073444.1739476-1-vedantparanjape160201@gmail.com>","X-Mailer":"git-send-email 2.25.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1] gstreamer: Add unit test to test\n\tsingle stream output","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 unit tests to check single stream output using\nlibcamera's gstreamer element.\n\nSigned-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n---\n .../gstreamer_single_stream_test.cpp          | 103 ++++++++++++++++++\n test/gstreamer/meson.build                    |  15 +++\n test/meson.build                              |   1 +\n 3 files changed, 119 insertions(+)\n create mode 100644 test/gstreamer/gstreamer_single_stream_test.cpp\n create mode 100644 test/gstreamer/meson.build","diff":"diff --git a/test/gstreamer/gstreamer_single_stream_test.cpp b/test/gstreamer/gstreamer_single_stream_test.cpp\nnew file mode 100644\nindex 00000000..cdd5cd9c\n--- /dev/null\n+++ b/test/gstreamer/gstreamer_single_stream_test.cpp\n@@ -0,0 +1,103 @@\n+#include <iostream>\n+#include <gst/gst.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+\n+class GstreamerSingleStreamTest: public Test\n+{\n+protected:\n+    int GstreamerPrintError(GstMessage *msg)\n+    {\n+        int TestResult = TestPass;\n+\n+        if (msg != NULL) {\n+            GError *err;\n+            gchar *debug_info;\n+\n+            switch (GST_MESSAGE_TYPE(msg)) {\n+                case GST_MESSAGE_ERROR:\n+                    gst_message_parse_error(msg, &err, &debug_info);\n+                    g_printerr(\"Error received from element %s: %s\\n\", GST_OBJECT_NAME(msg->src), err->message);\n+                    g_printerr(\"Debugging information: %s\\n\", debug_info ? debug_info : \"none\");\n+                    g_clear_error(&err);\n+                    g_free(debug_info);\n+                    TestResult = TestFail;\n+                    break;\n+                case GST_MESSAGE_EOS:\n+                    g_printerr(\"End-Of-Stream reached.\\n\");\n+                    TestResult = TestFail;\n+                    break;\n+                default:\n+                    /* We should not reach here because we only asked for ERRORs and EOS */\n+                    g_printerr(\"Unexpected message received.\\n\");\n+                    TestResult = TestFail;\n+                    break;\n+            }\n+        }\n+\n+        return TestResult;\n+    }\n+\n+    int run() override\n+    {\n+        GstElement *pipeline, *libcamera_src, *convert0, *sink0;\n+        GstBus *bus;\n+        GstMessage *msg;\n+        GstStateChangeReturn ret;\n+\n+        /* Initialize GStreamer */\n+        gst_init(nullptr, nullptr);\n+\n+        /* Create the elements */\n+        libcamera_src = gst_element_factory_make(\"libcamerasrc\", \"libcamera\");\n+        convert0 = gst_element_factory_make(\"videoconvert\", \"convert0\");\n+        sink0 = gst_element_factory_make(\"autovideosink\", \"sink0\");\n+\n+        /* Create the empty pipeline */\n+        pipeline = gst_pipeline_new(\"test-pipeline\");\n+\n+        if (!pipeline || !convert0 || !sink0 || !libcamera_src) {\n+            g_printerr(\"Not all elements could be created.\\n\");\n+            return TestFail;\n+        }\n+\n+        /* Build the pipeline */\n+        gst_bin_add_many(GST_BIN(pipeline), libcamera_src, convert0, sink0, NULL);\n+        if (gst_element_link_many(libcamera_src, convert0, sink0, NULL) != TRUE) {\n+            g_printerr(\"Elements could not be linked (1).\\n\");\n+            gst_object_unref(pipeline);\n+            return TestFail;\n+        }\n+\n+        /* Start playing */\n+        ret = gst_element_set_state(pipeline, GST_STATE_PLAYING);\n+        if (ret == GST_STATE_CHANGE_FAILURE) {\n+            g_printerr(\"Unable to set the pipeline to the playing state.\\n\");\n+            gst_object_unref(pipeline);\n+            return TestFail;\n+        }\n+\n+        /* Wait until error or EOS */\n+        GstClockTime timeout = 1000000000;\n+        bus = gst_element_get_bus(pipeline);\n+        msg = gst_bus_timed_pop_filtered(bus, timeout,\n+                                    GstMessageType((uint)GST_MESSAGE_ERROR | (uint)GST_MESSAGE_EOS));\n+\n+        /* Parse error message */\n+        if (GstreamerPrintError(msg) == TestFail) {\n+            return TestFail;\n+        }\n+        gst_message_unref(msg);\n+\n+        /* Free resources */\n+        gst_object_unref(bus);\n+        gst_element_set_state(pipeline, GST_STATE_NULL);\n+        gst_object_unref(pipeline);\n+\n+        return TestPass;\n+    }\n+};\n+\n+TEST_REGISTER(GstreamerSingleStreamTest)\ndiff --git a/test/gstreamer/meson.build b/test/gstreamer/meson.build\nnew file mode 100644\nindex 00000000..36643d4a\n--- /dev/null\n+++ b/test/gstreamer/meson.build\n@@ -0,0 +1,15 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+gstreamer_tests = [\n+    ['single_stream_test',   'gstreamer_single_stream_test.cpp'],\n+]\n+gstreamer_dep = dependency('gstreamer-1.0', required: true)\n+\n+foreach t : gstreamer_tests\n+    exe = executable(t[0], t[1],\n+                     dependencies : [libcamera_private, gstreamer_dep],\n+                     link_with : test_libraries,\n+                     include_directories : test_includes_internal)\n+\n+    test(t[0], exe, suite : 'gstreamer', is_parallel : false)\n+endforeach\ndiff --git a/test/meson.build b/test/meson.build\nindex 3bceb5df..d0466f17 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -11,6 +11,7 @@ subdir('libtest')\n \n subdir('camera')\n subdir('controls')\n+subdir('gstreamer')\n subdir('ipa')\n subdir('ipc')\n subdir('log')\n","prefixes":["libcamera-devel","v1"]}