{"id":13277,"url":"https://patchwork.libcamera.org/api/1.1/patches/13277/?format=json","web_url":"https://patchwork.libcamera.org/patch/13277/","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":"<20210810092409.1776260-1-vedantparanjape160201@gmail.com>","date":"2021-08-10T09:24:09","name":"[libcamera-devel,v3] test: gstreamer: Add test for gstreamer single stream","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"a531e982104306dc842f1d67321e46b8a2909c1b","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/13277/mbox/","series":[{"id":2329,"url":"https://patchwork.libcamera.org/api/1.1/series/2329/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2329","date":"2021-08-10T09:24:09","name":"[libcamera-devel,v3] test: gstreamer: Add test for gstreamer single stream","version":3,"mbox":"https://patchwork.libcamera.org/series/2329/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13277/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13277/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 45092C3240\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 10 Aug 2021 09:24:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AF15868826;\n\tTue, 10 Aug 2021 11:24:29 +0200 (CEST)","from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com\n\t[IPv6:2607:f8b0:4864:20::1033])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5FCC6687DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Aug 2021 11:24:27 +0200 (CEST)","by mail-pj1-x1033.google.com with SMTP id\n\tm24-20020a17090a7f98b0290178b1a81700so4367938pjl.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Aug 2021 02:24:27 -0700 (PDT)","from localhost.localdomain ([1.186.167.156])\n\tby smtp.googlemail.com with ESMTPSA id\n\t23sm9095553pgk.89.2021.08.10.02.24.24\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 10 Aug 2021 02:24:25 -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=\"f95vHnnb\"; 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=G3HoTG6AhGq2GP7nxXoNwpwIuz2C32lHEu+XhlsES+4=;\n\tb=f95vHnnb1WncnYKnMDGlBPqQq8YCCWTw1GcRr5IuJBgnw5ieYnkIdcn1kwMjDgAQb7\n\tPViheO6pzrVq4NOscdkcNtXC/UmIFpTORXBuKwIUJFBoJCu/7BosyxM1qpys3QGoM9+K\n\tuazURFYoifqZWwPO3OfzwcptcHr424xofkFlk1/gPrDUD8CKC5sTIeW8KOIarn2m17e2\n\tjbl6qd/X8Kx5FDMoTv08i3y3reCWSzxqWAhtawYtWlyoMuGKosTHDcBx6JBQk+KoCJLh\n\tI9Wa5VD3/Mo7Ah6WlN84pFid3OfawOExREO2m0Y0TYN37FEg3V4i7pl6esbnELBrPWh9\n\tSmsw==","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=G3HoTG6AhGq2GP7nxXoNwpwIuz2C32lHEu+XhlsES+4=;\n\tb=XtExef9lYl2OUZtwZpEBo8hlQ58+v0hVTiHXFuZjAEe7pD3rRIsnkFseBXDWHixF2O\n\tG3qGFGb3eqGiaiTZ3tbGmwjWeWNd37iu0Od6BnxlBly++NBrc1T2b7DiLkXlhUQkr2FK\n\tQ0h1dppf4qCh5ucRqSlVrCHGynvDozBytf84g7OeVNMBddYZj4BCozvzyp+DLvDhT8R1\n\tyDnd/wlCOwL17HSUVA7CotdvEeXt1t9S14zHgWLe48QGFfEpCjaiRQu5yRpmlk//4QX9\n\tzeaZ0sHApXMlI3fimpw7BOPZg3bnA8cLDZGg8NktEYPqmqzH7ro86RcaFo/Lq2+uuPrR\n\tpmsA==","X-Gm-Message-State":"AOAM532W6qoKd9+BF1e/RCyBY6uSvmgyqiSs3EAr6odXp9EzjHw0NpH9\n\tCn10pHeJSztLV6fugenUtnHJqsmlpOmQjA==","X-Google-Smtp-Source":"ABdhPJxWI2zdk3CU7yHBImyrp4Kz4ZWCU9aip3coqjRiiBiDfTnPx1vfE+Bw6r3Mc16VrHtZquZXXg==","X-Received":"by 2002:a17:902:6a83:b029:12d:e47:90b0 with SMTP id\n\tn3-20020a1709026a83b029012d0e4790b0mr12575119plk.18.1628587465609; \n\tTue, 10 Aug 2021 02:24:25 -0700 (PDT)","From":"Vedant Paranjape <vedantparanjape160201@gmail.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 10 Aug 2021 14:54:09 +0530","Message-Id":"<20210810092409.1776260-1-vedantparanjape160201@gmail.com>","X-Mailer":"git-send-email 2.25.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3] test: gstreamer: Add test for\n\tgstreamer single 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":"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 a test to test if single stream using\nlibcamera's gstreamer element works.\n\nSigned-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n---\n .../gstreamer_single_stream_test.cpp          | 119 ++++++++++++++++++\n test/gstreamer/meson.build                    |  15 +++\n test/meson.build                              |   1 +\n 3 files changed, 135 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..11f55e1c\n--- /dev/null\n+++ b/test/gstreamer/gstreamer_single_stream_test.cpp\n@@ -0,0 +1,119 @@\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+private:\n+\tGstElement *pipeline_, *libcamera_src_, *convert0_, *sink0_;\n+\tGstBus *bus_;\n+\tGstMessage *msg_;\n+\tGstStateChangeReturn ret_;\n+\n+protected:\n+\tvoid GstreamerPrintError(GstMessage *msg)\n+\t{\n+\t\tGError *err;\n+\t\tgchar *debug_info;\n+\n+\t\tgst_message_parse_error(msg, &err, &debug_info);\n+\t\tg_printerr(\"Error received from element %s: %s\\n\", GST_OBJECT_NAME(msg->src), err->message);\n+\t\tg_printerr(\"Debugging information: %s\\n\", debug_info ? debug_info : \"none\");\n+\t\tg_clear_error(&err);\n+\t\tg_free(debug_info);\n+\t}\n+\n+\tint init() override\n+\t{\n+\t\t/* Initialize GStreamer */\n+\t\tGError *err_init = nullptr;\n+\t\tif (!gst_init_check(nullptr, nullptr, &err_init)) {\n+\t\t\tg_printerr (\"Could not initialize GStreamer: %s\\n\", \n+\t\t\t\t\t\t\terr_init ? err_init->message : \"unknown error\");\n+\t\t\tif (err_init)\n+\t\t\t\tg_error_free(err_init);\n+\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Create the elements */\n+\t\tlibcamera_src_ = gst_element_factory_make(\"libcamerasrc\", \"libcamera\");\n+\t\tconvert0_ = gst_element_factory_make(\"videoconvert\", \"convert0\");\n+\t\tsink0_ = gst_element_factory_make(\"autovideosink\", \"sink0\");\n+\n+\t\t/* Create the empty pipeline_ */\n+\t\tpipeline_ = gst_pipeline_new(\"test-pipeline\");\n+\n+\t\tif (!pipeline_ || !convert0_ || !sink0_ || !libcamera_src_) {\n+\t\t\tg_printerr(\"Not all elements could be created.\\n\");\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tvoid cleanup() override\n+\t{\n+\t\tgst_message_unref(msg_);\n+\t\tgst_object_unref(bus_);\n+\t\tgst_element_set_state(pipeline_, GST_STATE_NULL);\n+\t\tgst_object_unref(pipeline_);\n+\t}\n+\n+\tint run() override\n+\t{\n+\t\t/* Build the pipeline */\n+\t\tgst_bin_add_many(GST_BIN(pipeline_), libcamera_src_, convert0_, sink0_, NULL);\n+\t\tif (gst_element_link_many(libcamera_src_, convert0_, sink0_, NULL) != TRUE) {\n+\t\t\tg_printerr(\"Elements could not be linked.\\n\");\n+\t\t\tgst_object_unref(pipeline_);\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Start playing */\n+\t\tret_ = gst_element_set_state(pipeline_, GST_STATE_PLAYING);\n+\t\tif (ret_ == GST_STATE_CHANGE_FAILURE) {\n+\t\t\tg_printerr(\"Unable to set the pipeline to the playing state.\\n\");\n+\t\t\tgst_object_unref(pipeline_);\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Wait until error or EOS or timeout after 2 seconds*/\n+\t\tGstClockTime timeout = 2000000000;\n+\t\tbus_ = gst_element_get_bus(pipeline_);\n+\t\tmsg_ = gst_bus_timed_pop_filtered(bus_, timeout,\n+\t\t\t\t\t\t\t\t\tGstMessageType((uint)GST_MESSAGE_ERROR | (uint)GST_MESSAGE_EOS));\n+\n+\t\t/* Parse error message */\n+\t\tif (msg_ != NULL) {\n+\t\t\tint TestResult;\n+\n+\t\t\tswitch (GST_MESSAGE_TYPE(msg_)) {\n+\t\t\t\tcase GST_MESSAGE_ERROR:\n+\t\t\t\t\tGstreamerPrintError(msg_);\n+\t\t\t\t\tTestResult = TestFail;\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase GST_MESSAGE_EOS:\n+\t\t\t\t\tg_print(\"End-Of-Stream reached.\\n\");\n+\t\t\t\t\tTestResult = TestFail;\n+\t\t\t\t\tbreak;\n+\t\t\t\tdefault:\n+\t\t\t\t\t/* We should not reach here because we only asked for ERRORs and EOS */\n+\t\t\t\t\tg_printerr(\"Unexpected message received.\\n\");\n+\t\t\t\t\tTestResult = TestFail;\n+\t\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tif (TestResult == TestFail) {\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\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","v3"]}