{"id":23945,"url":"https://patchwork.libcamera.org/api/patches/23945/?format=json","web_url":"https://patchwork.libcamera.org/patch/23945/","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":"<20250724133343.353044-3-uajain@igalia.com>","date":"2025-07-24T13:33:42","name":"[v4,2/3] gstreamer: Move existing GValue helpers to gstreamer-utils","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"126e821e795ba45fd2c90643c47c0b0f4f1041c7","submitter":{"id":232,"url":"https://patchwork.libcamera.org/api/people/232/?format=json","name":"Umang Jain","email":"uajain@igalia.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23945/mbox/","series":[{"id":5323,"url":"https://patchwork.libcamera.org/api/series/5323/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5323","date":"2025-07-24T13:33:41","name":"gstreamer: Report camera properties as device properties","version":4,"mbox":"https://patchwork.libcamera.org/series/5323/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23945/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23945/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 0F5F7C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Jul 2025 13:33:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B81E769113;\n\tThu, 24 Jul 2025 15:33:45 +0200 (CEST)","from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E133690E2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Jul 2025 15:33:40 +0200 (CEST)","from [49.36.71.87] (helo=uajain) by fanzine2.igalia.com with\n\tesmtpsa \n\t(Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)\n\t(Exim) id 1uew4p-003CfR-LY; Thu, 24 Jul 2025 15:33:39 +0200"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=igalia.com header.i=@igalia.com\n\theader.b=\"HcVNMUio\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com;\n\ts=20170329;\n\th=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:\n\tList-Post:List-Owner:List-Archive;\n\tbh=UHjzVogniDdtowpyr43n+0zMp/Zvz9BPrsPIlLPyp4w=;\n\tb=HcVNMUiotXJrC/AmP4FG7sIyar\n\tQPJT/GZT/BYjxo7cYQ67Fkz2sUZXn9WpmSRJdWtrRs/Za9377YZdiJ+PTFnLPLRYjWG5AE4rpHZH/\n\tW7ud1p8xP/FsTdS09QsBf0pLQs00u+op7paND4OnGDiq8TvYg1zYkGD8oHwZ3AJsdqgJ6F1Is86U8\n\trtf+uVVyMRyVj1P4BU4jzEueqstI0VEcx+0/8d2HBbpLeis4VkycSP3Zrl507iGBdcsSBPqPldVcW\n\tblcGBouRnPyfGD2k3SGBNF/SuZw/gaHpr6oguH+emHIrQNgpKCymYmETqHKjLDQ+vEea7QNyohVMs\n\tMTwAfFkg==;","From":"Umang Jain <uajain@igalia.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Jaslo Ziska <jaslo@ziska.de>,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>,\n\tUmang Jain <uajain@igalia.com>","Subject":"[PATCH v4 2/3] gstreamer: Move existing GValue helpers to\n\tgstreamer-utils","Date":"Thu, 24 Jul 2025 19:03:42 +0530","Message-ID":"<20250724133343.353044-3-uajain@igalia.com>","X-Mailer":"git-send-email 2.50.0","In-Reply-To":"<20250724133343.353044-1-uajain@igalia.com>","References":"<20250724133343.353044-1-uajain@igalia.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Move the existing GValue helpers from gstlibcamera-controls.cpp.in\nto gstreamer-utils.cpp. The intention here is to make these helpers\navailable to other parts of gstreamer source element, for example,\nreporting camera properties in GstDeviceProvider.\n\nThe function signature has been changed to match with the other\ngstreamer-utils utility functions:\n\nvalue_get_rectangle() =>  gst_libcamera_gvalue_get_rectangle()\nvalue_set_rectangle() =>  gst_libcamera_gvalue_set_rectangle()\nvalue_set_point()     =>  gst_libcamera_gvalue_set_point()\nvalue_set_size()      =>  gst_libcamera_gvalue_set_size()\n\nSigned-off-by: Umang Jain <uajain@igalia.com>\n---\n src/gstreamer/gstlibcamera-controls.cpp.in | 56 ++--------------------\n src/gstreamer/gstlibcamera-utils.cpp       | 47 ++++++++++++++++++\n src/gstreamer/gstlibcamera-utils.h         |  4 ++\n 3 files changed, 56 insertions(+), 51 deletions(-)","diff":"diff --git a/src/gstreamer/gstlibcamera-controls.cpp.in b/src/gstreamer/gstlibcamera-controls.cpp.in\nindex 1bc781cc..6faf3ee7 100644\n--- a/src/gstreamer/gstlibcamera-controls.cpp.in\n+++ b/src/gstreamer/gstlibcamera-controls.cpp.in\n@@ -14,56 +14,10 @@\n #include <libcamera/geometry.h>\n \n #include \"gstlibcamera-controls.h\"\n+#include \"gstlibcamera-utils.h\"\n \n using namespace libcamera;\n \n-static void value_set_point(GValue *value, const Point &point)\n-{\n-\tGValue x = G_VALUE_INIT;\n-\tg_value_init(&x, G_TYPE_INT);\n-\tg_value_set_int(&x, point.x);\n-\tgst_value_array_append_and_take_value(value, &x);\n-\n-\tGValue y = G_VALUE_INIT;\n-\tg_value_init(&y, G_TYPE_INT);\n-\tg_value_set_int(&y, point.y);\n-\tgst_value_array_append_and_take_value(value, &y);\n-}\n-\n-static void value_set_size(GValue *value, const Size &size)\n-{\n-\tGValue width = G_VALUE_INIT;\n-\tg_value_init(&width, G_TYPE_INT);\n-\tg_value_set_int(&width, size.width);\n-\tgst_value_array_append_and_take_value(value, &width);\n-\n-\tGValue height = G_VALUE_INIT;\n-\tg_value_init(&height, G_TYPE_INT);\n-\tg_value_set_int(&height, size.height);\n-\tgst_value_array_append_and_take_value(value, &height);\n-}\n-\n-static void value_set_rectangle(GValue *value, const Rectangle &rect)\n-{\n-\tvalue_set_point(value, rect.topLeft());\n-\tvalue_set_size(value, rect.size());\n-}\n-\n-static Rectangle value_get_rectangle(const GValue *value)\n-{\n-\tconst GValue *r;\n-\tr = gst_value_array_get_value(value, 0);\n-\tint x = g_value_get_int(r);\n-\tr = gst_value_array_get_value(value, 1);\n-\tint y = g_value_get_int(r);\n-\tr = gst_value_array_get_value(value, 2);\n-\tint w = g_value_get_int(r);\n-\tr = gst_value_array_get_value(value, 3);\n-\tint h = g_value_get_int(r);\n-\n-\treturn Rectangle(x, y, w, h);\n-}\n-\n {% for vendor, ctrls in controls %}\n {%- for ctrl in ctrls if ctrl.is_enum %}\n static const GEnumValue {{ ctrl.name|snake_case }}_types[] = {\n@@ -179,7 +133,7 @@ bool GstCameraControls::getProperty(guint propId, GValue *value,\n \t\t\tGValue element = G_VALUE_INIT;\n {%- if ctrl.is_rectangle %}\n \t\t\tg_value_init(&element, GST_TYPE_PARAM_ARRAY_LIST);\n-\t\t\tvalue_set_rectangle(&element, control[i]);\n+\t\t\tgst_libcamera_gvalue_set_rectangle(&element, control[i]);\n {%- else %}\n \t\t\tg_value_init(&element, G_TYPE_{{ ctrl.gtype|upper }});\n \t\t\tg_value_set_{{ ctrl.gtype }}(&element, control[i]);\n@@ -188,7 +142,7 @@ bool GstCameraControls::getProperty(guint propId, GValue *value,\n \t\t}\n {%- else %}\n {%- if ctrl.is_rectangle %}\n-\t\tvalue_set_rectangle(value, control);\n+\t\tgst_libcamera_gvalue_set_rectangle(value, control);\n {%- else %}\n \t\tg_value_set_{{ ctrl.gtype }}(value, control);\n {%- endif %}\n@@ -252,7 +206,7 @@ bool GstCameraControls::setProperty(guint propId, const GValue *value,\n \t\t\t\t\t  i);\n \t\t\t\treturn true;\n \t\t\t}\n-\t\t\tvalues[i] = value_get_rectangle(element);\n+\t\t\tvalues[i] = gst_libcamera_gvalue_get_rectangle(element);\n {%- else %}\n \t\t\tvalues[i] = g_value_get_{{ ctrl.gtype }}(element);\n {%- endif %}\n@@ -271,7 +225,7 @@ bool GstCameraControls::setProperty(guint propId, const GValue *value,\n \t\t\t\t  \"array of size 4\");\n \t\t\treturn true;\n \t\t}\n-\t\tRectangle val = value_get_rectangle(value);\n+\t\tRectangle val = gst_libcamera_gvalue_get_rectangle(value);\n {%- else %}\n \t\tauto val = g_value_get_{{ ctrl.gtype }}(value);\n {%- endif %}\ndiff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp\nindex a548b0c1..63e00fe0 100644\n--- a/src/gstreamer/gstlibcamera-utils.cpp\n+++ b/src/gstreamer/gstlibcamera-utils.cpp\n@@ -584,6 +584,53 @@ void gst_libcamera_framerate_to_caps(GstCaps *caps, const GstStructure *element_\n \tgst_structure_set(s, \"framerate\", GST_TYPE_FRACTION, fps_caps_n, fps_caps_d, nullptr);\n }\n \n+void gst_libcamera_gvalue_set_point(GValue *value, const Point &point)\n+{\n+\tGValue x = G_VALUE_INIT;\n+\tg_value_init(&x, G_TYPE_INT);\n+\tg_value_set_int(&x, point.x);\n+\tgst_value_array_append_and_take_value(value, &x);\n+\n+\tGValue y = G_VALUE_INIT;\n+\tg_value_init(&y, G_TYPE_INT);\n+\tg_value_set_int(&y, point.y);\n+\tgst_value_array_append_and_take_value(value, &y);\n+}\n+\n+void gst_libcamera_gvalue_set_size(GValue *value, const Size &size)\n+{\n+\tGValue width = G_VALUE_INIT;\n+\tg_value_init(&width, G_TYPE_INT);\n+\tg_value_set_int(&width, size.width);\n+\tgst_value_array_append_and_take_value(value, &width);\n+\n+\tGValue height = G_VALUE_INIT;\n+\tg_value_init(&height, G_TYPE_INT);\n+\tg_value_set_int(&height, size.height);\n+\tgst_value_array_append_and_take_value(value, &height);\n+}\n+\n+void gst_libcamera_gvalue_set_rectangle(GValue *value, const Rectangle &rect)\n+{\n+\tgst_libcamera_gvalue_set_point(value, rect.topLeft());\n+\tgst_libcamera_gvalue_set_size(value, rect.size());\n+}\n+\n+Rectangle gst_libcamera_gvalue_get_rectangle(const GValue *value)\n+{\n+\tconst GValue *r;\n+\tr = gst_value_array_get_value(value, 0);\n+\tint x = g_value_get_int(r);\n+\tr = gst_value_array_get_value(value, 1);\n+\tint y = g_value_get_int(r);\n+\tr = gst_value_array_get_value(value, 2);\n+\tint w = g_value_get_int(r);\n+\tr = gst_value_array_get_value(value, 3);\n+\tint h = g_value_get_int(r);\n+\n+\treturn Rectangle(x, y, w, h);\n+}\n+\n #if !GST_CHECK_VERSION(1, 17, 1)\n gboolean\n gst_task_resume(GstTask *task)\ndiff --git a/src/gstreamer/gstlibcamera-utils.h b/src/gstreamer/gstlibcamera-utils.h\nindex 5f4e8a0f..1812be75 100644\n--- a/src/gstreamer/gstlibcamera-utils.h\n+++ b/src/gstreamer/gstlibcamera-utils.h\n@@ -25,6 +25,10 @@ void gst_libcamera_clamp_and_set_frameduration(libcamera::ControlList &controls,\n \t\t\t\t\t       const libcamera::ControlInfoMap &camera_controls,\n \t\t\t\t\t       GstStructure *element_caps);\n void gst_libcamera_framerate_to_caps(GstCaps *caps, const GstStructure *element_caps);\n+void gst_libcamera_gvalue_set_point(GValue *value, const libcamera::Point &point);\n+void gst_libcamera_gvalue_set_size(GValue *value, const libcamera::Size &size);\n+void gst_libcamera_gvalue_set_rectangle(GValue *value, const libcamera::Rectangle &rect);\n+libcamera::Rectangle gst_libcamera_gvalue_get_rectangle(const GValue *value);\n \n #if !GST_CHECK_VERSION(1, 16, 0)\n static inline void gst_clear_event(GstEvent **event_ptr)\n","prefixes":["v4","2/3"]}