From patchwork Thu Sep 23 13:46:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vedant Paranjape X-Patchwork-Id: 13912 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9B7EABDC71 for ; Thu, 23 Sep 2021 13:47:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 173146918E; Thu, 23 Sep 2021 15:47:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kQNvqKPV"; dkim-atps=neutral Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D70E769189 for ; Thu, 23 Sep 2021 15:47:08 +0200 (CEST) Received: by mail-pg1-x529.google.com with SMTP id f129so6402784pgc.1 for ; Thu, 23 Sep 2021 06:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tH7Gi4/2jtRGwGaPA5Qv1ukDDDjAu54TslzbkGJmDCc=; b=kQNvqKPVXz5xh5ZRJGUB54b8l37GbpnJuU8Q6Vwi4FTyyBjVFKoJWckbtqarY/nsGd LN3V5BiF1mlptV/u3D2z9cD1QMMCxM04YaJpdaWVBYU0mNHBAwYxf/tiooqNV3oHgqZD 7pd50fhz1jRY244AvhzPYiRv1eaD0mKxb7h9bCwhzZ/KEXa1Sr+USCvH+n1QXSvwqLD+ QHmKTjDYkqwci3dcJsI/vNu2NOFYyECJQa2FY+JSyq4cyuHEx38oYUjMXXvKvgttjQV+ oK8RO65X4LyCqekdxveCb21l6n4I6PMXck2MiVgCdGHLsyCRXNU1GIuA4T6JarOqp8dz dsQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tH7Gi4/2jtRGwGaPA5Qv1ukDDDjAu54TslzbkGJmDCc=; b=MQkJsDh3c5p2yfMF27JaNSO9ZrC2QtBo8QyLKehqlDFPj+iLp0RyosZQkAhs1QyX/R ltqMWrdab0Ux657mgGbOQZyBIi73ALEDbbvBA9UMFtUyIVO32h7Q1Dw/YSo3WB5/w4Pq cgwvS/AmV6ZRgW6gVldVsRGBa1Lve9bvdWBTwgFVdEJQ9Agb3LdG9VmcXK6Aexybr9da c2WSx8j4fJeUgCq+mGCCMHi66Kh0DYElCBTEpMNXg3rzv8YawvDJJ0jGSffzhY8j6an3 GqZrr0giKQu1rF2kDwE/QUoQuH7mmq80s39/qC/nPyKj1MFt33RxOC0hQlV/zPIU2p5k V0aw== X-Gm-Message-State: AOAM530eCuLmWOFNkrz2QUDo72HnpYH8dypsqURWeDanbbGa2w5QbaSD aNCM0m4w9TZ1j8rxMNsUkMjviJF15FqVMgmK X-Google-Smtp-Source: ABdhPJyMUSoBr+ZJgZzyuFccuavPzb140F5mZe8UsqK/02B8g9fO1uhvgPdf7pRzhwXVrtMuhNe1sA== X-Received: by 2002:a63:4301:: with SMTP id q1mr1851611pga.430.1632404826906; Thu, 23 Sep 2021 06:47:06 -0700 (PDT) Received: from localhost.localdomain ([1.186.166.66]) by smtp.googlemail.com with ESMTPSA id t8sm9146195pjt.39.2021.09.23.06.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 06:47:06 -0700 (PDT) From: Vedant Paranjape To: libcamera-devel@lists.libcamera.org Date: Thu, 23 Sep 2021 19:16:53 +0530 Message-Id: <20210923134653.1612991-1-vedantparanjape160201@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] test: gstreamer: Add a test for gstreamer multi stream X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicolas Dufresne , Vedant Paranjape Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This patch adds a test to test if multi stream using libcamera's gstreamer element works. Test will run only on devices that support multistream output, i.e., devices that use IPU3 and raspberrypi pipeline. This was tested on a Raspberry Pi 4B+. Signed-off-by: Vedant Paranjape Reviewed-by: Nicolas Dufresne --- .../gstreamer/gstreamer_multi_stream_test.cpp | 121 ++++++++++++++++++ test/gstreamer/meson.build | 1 + 2 files changed, 122 insertions(+) create mode 100644 test/gstreamer/gstreamer_multi_stream_test.cpp diff --git a/test/gstreamer/gstreamer_multi_stream_test.cpp b/test/gstreamer/gstreamer_multi_stream_test.cpp new file mode 100644 index 000000000000..5df1dd40388a --- /dev/null +++ b/test/gstreamer/gstreamer_multi_stream_test.cpp @@ -0,0 +1,121 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2021, Vedant Paranjape + * + * gstreamer_multi_stream_test.cpp - GStreamer multi stream capture test + */ + +#include +#include + +#include + +#include + +#include "libcamera/internal/source_paths.h" + +#include + +#include "gstreamer_test.h" +#include "test.h" + +using namespace std; + +class GstreamerMultiStreamTest : public GstreamerTest, public Test +{ +public: + GstreamerMultiStreamTest() + : GstreamerTest() + { + } + +protected: + int init() override + { + if (status_ != TestPass) + return status_; + + /* Check if platform support multistream output */ + libcamera::CameraManager cm; + cm.start(); + bool cameraFound = false; + for (auto &camera : cm.cameras()) { + if (camera->streams().size() > 1) { + cameraName = camera->id(); + cameraFound = true; + cm.stop(); + break; + } + } + + if (!cameraFound) { + cm.stop(); + return TestSkip; + } + + const gchar *streamDescription = "queue ! fakesink"; + g_autoptr(GError) error0 = NULL; + g_autoptr(GError) error1 = NULL; + stream0_ = gst_parse_bin_from_description_full(streamDescription, TRUE, NULL, GST_PARSE_FLAG_FATAL_ERRORS, &error0); + stream1_ = gst_parse_bin_from_description_full(streamDescription, TRUE, NULL, GST_PARSE_FLAG_FATAL_ERRORS, &error1); + + if (!stream0_) { + g_printerr("Bin 0 could not be created (%s)\n", error0->message); + return TestFail; + } + if (!stream1_) { + g_printerr("Bin 1 could not be created (%s)\n", error1->message); + return TestFail; + } + g_object_ref_sink(stream0_); + g_object_ref_sink(stream1_); + + if (createPipeline() != TestPass) + return TestFail; + + return TestPass; + } + + int run() override + { + g_object_set(libcameraSrc_, "camera-name", cameraName.c_str(), NULL); + + /* Build the pipeline */ + gst_bin_add_many(GST_BIN(pipeline_), libcameraSrc_, + stream0_, stream1_, NULL); + + g_autoptr(GstPad) src_pad = gst_element_get_static_pad(libcameraSrc_, "src"); + g_autoptr(GstPad) request_pad = gst_element_get_request_pad(libcameraSrc_, "src_%u"); + + { + g_autoptr(GstPad) queue0_sink_pad = gst_element_get_static_pad(stream0_, "sink"); + g_autoptr(GstPad) queue1_sink_pad = gst_element_get_static_pad(stream1_, "sink"); + + if (gst_pad_link(src_pad, queue0_sink_pad) != GST_PAD_LINK_OK + || gst_pad_link(request_pad, queue1_sink_pad) != GST_PAD_LINK_OK) { + g_printerr("Pads could not be linked.\n"); + return TestFail; + } + } + + if (startPipeline() != TestPass) + return TestFail; + + if (processEvent() != TestPass) + return TestFail; + + return TestPass; + } + + void cleanup() override + { + g_clear_object(&stream0_); + g_clear_object(&stream1_); + } +private: + std::string cameraName; + GstElement *stream0_; + GstElement *stream1_; +}; + +TEST_REGISTER(GstreamerMultiStreamTest) diff --git a/test/gstreamer/meson.build b/test/gstreamer/meson.build index aca53b920365..13652e87d05c 100644 --- a/test/gstreamer/meson.build +++ b/test/gstreamer/meson.build @@ -6,6 +6,7 @@ endif gstreamer_tests = [ ['single_stream_test', 'gstreamer_single_stream_test.cpp'], + ['multi_stream_test', 'gstreamer_multi_stream_test.cpp'], ] gstreamer_dep = dependency('gstreamer-1.0', required: true)