[{"id":19767,"web_url":"https://patchwork.libcamera.org/comment/19767/","msgid":"<20210922045612.GC4382@pyrite.rasen.tech>","date":"2021-09-22T04:56:12","subject":"Re: [libcamera-devel] [PATCH v2 2/3] test: gstreamer: Simplify\n\tsingle stream test using functions from GstUtils","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Vedant,\n\nOn Tue, Sep 21, 2021 at 11:09:54PM +0530, Vedant Paranjape wrote:\n> Simplify memory handling and complexity of the test by using\n> gst_parse_bin_from_description_full [1].\n> \n> [1]: https://gstreamer.freedesktop.org/documentation/gstreamer/gstutils.html?gi-language=c#gst_parse_bin_from_description_full\n> \n> Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com>\n> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  .../gstreamer_single_stream_test.cpp          | 32 ++++++++-----------\n>  1 file changed, 14 insertions(+), 18 deletions(-)\n> \n> diff --git a/test/gstreamer/gstreamer_single_stream_test.cpp b/test/gstreamer/gstreamer_single_stream_test.cpp\n> index 2b561d6bf9f2..bd74ada0e244 100644\n> --- a/test/gstreamer/gstreamer_single_stream_test.cpp\n> +++ b/test/gstreamer/gstreamer_single_stream_test.cpp\n> @@ -33,20 +33,18 @@ protected:\n>  \t\tif (status_ != TestPass)\n>  \t\t\treturn status_;\n>  \n> -\t\tg_autoptr(GstElement) convert0 = gst_element_factory_make(\"videoconvert\", \"convert0\");\n> -\t\tg_autoptr(GstElement) sink0 = gst_element_factory_make(\"fakesink\", \"sink0\");\n> -\t\tg_object_ref_sink(convert0);\n> -\t\tg_object_ref_sink(sink0);\n> -\n> -\t\tif (!convert0 || !sink0) {\n> -\t\t\tg_printerr(\"Not all elements could be created. %p.%p\\n\",\n> -\t\t\t\t   convert0, sink0);\n> -\n> +\t\tconst gchar *streamDescription = \"videoconvert ! fakesink\";\n> +\t\tg_autoptr(GError) error0 = NULL;\n> +\t\tstream0_ = gst_parse_bin_from_description_full(streamDescription, TRUE,\n> +\t\t\t\t\t\tNULL,\n> +\t\t\t\t\t\tGST_PARSE_FLAG_FATAL_ERRORS,\n> +\t\t\t\t\t\t&error0);\n> +\n> +\t\tif (!stream0_) {\n> +\t\t\tg_printerr(\"Bin could not be created (%s)\\n\", error0->message);\n>  \t\t\treturn TestFail;\n>  \t\t}\n> -\n> -\t\tconvert0_ = reinterpret_cast<GstElement *>(g_steal_pointer(&convert0));\n> -\t\tsink0_ = reinterpret_cast<GstElement *>(g_steal_pointer(&sink0));\n> +\t\tg_object_ref_sink(stream0_);\n>  \n>  \t\tif (createPipeline() != TestPass)\n>  \t\t\treturn TestFail;\n> @@ -57,8 +55,8 @@ protected:\n>  \tint run() override\n>  \t{\n>  \t\t/* Build the pipeline */\n> -\t\tgst_bin_add_many(GST_BIN(pipeline_), libcameraSrc_, convert0_, sink0_, NULL);\n> -\t\tif (gst_element_link_many(libcameraSrc_, convert0_, sink0_, NULL) != TRUE) {\n> +\t\tgst_bin_add_many(GST_BIN(pipeline_), libcameraSrc_, stream0_, NULL);\n> +\t\tif (gst_element_link(libcameraSrc_, stream0_) != TRUE) {\n>  \t\t\tg_printerr(\"Elements could not be linked.\\n\");\n>  \t\t\treturn TestFail;\n>  \t\t}\n> @@ -74,13 +72,11 @@ protected:\n>  \n>  \tvoid cleanup() override\n>  \t{\n> -\t\tg_clear_object(&convert0_);\n> -\t\tg_clear_object(&sink0_);\n> +\t\tg_clear_object(&stream0_);\n>  \t}\n>  \n>  private:\n> -\tGstElement *convert0_;\n> -\tGstElement *sink0_;\n> +\tGstElement *stream0_;\n>  };\n>  \n>  TEST_REGISTER(GstreamerSingleStreamTest)\n> -- \n> 2.25.1\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 684EBBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Sep 2021 04:56:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3B12D6918C;\n\tWed, 22 Sep 2021 06:56:23 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 813A56012C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Sep 2021 06:56:21 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BBCF2F1;\n\tWed, 22 Sep 2021 06:56:19 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"S7DNemtY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632286581;\n\tbh=YdBT0BA8LQM6q+QvFqR54lhdQqgDDvr6zWzkUdypFUw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=S7DNemtYKI8qPN+7PohyyuFHeYD6La/ptKqvRdnH0a3meFmEV+omt9OcXxzxOagOR\n\teO17A6Q3r0IGAosOERJaHQ2q02f9k/G3EpjsrWYXBE7U8cJm8od6A0KpA1pbcjCWH6\n\t/6o9al9gdXHZ+TJq1fV8o9AtvwceHxbBDY81zBa4=","Date":"Wed, 22 Sep 2021 13:56:12 +0900","From":"paul.elder@ideasonboard.com","To":"Vedant Paranjape <vedantparanjape160201@gmail.com>","Message-ID":"<20210922045612.GC4382@pyrite.rasen.tech>","References":"<20210921173955.20408-1-vedantparanjape160201@gmail.com>\n\t<20210921173955.20408-2-vedantparanjape160201@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20210921173955.20408-2-vedantparanjape160201@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2 2/3] test: gstreamer: Simplify\n\tsingle stream test using functions from GstUtils","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":"libcamera-devel@lists.libcamera.org,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]