{"id":20211,"url":"https://patchwork.libcamera.org/api/1.1/patches/20211/?format=json","web_url":"https://patchwork.libcamera.org/patch/20211/","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":"<20240605174447.139942-2-nicolas@ndufresne.ca>","date":"2024-06-05T17:44:46","name":"[v2,1/2] gst: Add child proxy support to libcamerasrc","commit_ref":"a1549129d3e75ddf67074cbc070c9798063dcc6c","pull_url":null,"state":"accepted","archived":false,"hash":"5e8c6ff32074d7bcc33adbf820dded98d66cc3d1","submitter":{"id":30,"url":"https://patchwork.libcamera.org/api/1.1/people/30/?format=json","name":"Nicolas Dufresne","email":"nicolas@ndufresne.ca"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20211/mbox/","series":[{"id":4365,"url":"https://patchwork.libcamera.org/api/1.1/series/4365/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4365","date":"2024-06-05T17:44:45","name":"Document libcamerasrc multi stream usage","version":2,"mbox":"https://patchwork.libcamera.org/series/4365/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20211/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20211/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 E50C9C32C8\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jun 2024 17:45:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4FD5E6544A;\n\tWed,  5 Jun 2024 19:45:06 +0200 (CEST)","from madrid.collaboradmins.com (madrid.collaboradmins.com\n\t[46.235.227.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3184A6544A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jun 2024 19:45:03 +0200 (CEST)","from nicolas-tpx395.lan (cola.collaboradmins.com [195.201.22.229])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (4096 bits)\n\tserver-digest SHA256)\n\t(No client certificate requested) (Authenticated sender: nicolas)\n\tby madrid.collaboradmins.com (Postfix) with ESMTPSA id 2FDF6378020A; \n\tWed,  5 Jun 2024 17:45:02 +0000 (UTC)"],"From":"Nicolas Dufresne <nicolas@ndufresne.ca>","To":"libcamera-devel@lists.libcamera.org","Cc":"Nicolas Dufresne <nicolas.dufresne@collabora.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"[PATCH v2 1/2] gst: Add child proxy support to libcamerasrc","Date":"Wed,  5 Jun 2024 13:44:46 -0400","Message-ID":"<20240605174447.139942-2-nicolas@ndufresne.ca>","X-Mailer":"git-send-email 2.45.1","In-Reply-To":"<20240605174447.139942-1-nicolas@ndufresne.ca>","References":"<20240605174447.139942-1-nicolas@ndufresne.ca>","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":"From: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n\nThe child proxy interface is needed in order to allow setting\nproperties on pad using parse launch syntax.\n\nSigned-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/gstreamer/gstlibcamerasrc.cpp | 45 +++++++++++++++++++++++++++++--\n 1 file changed, 43 insertions(+), 2 deletions(-)","diff":"diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex 9680d809..e1bb6b4c 100644\n--- a/src/gstreamer/gstlibcamerasrc.cpp\n+++ b/src/gstreamer/gstlibcamerasrc.cpp\n@@ -157,7 +157,12 @@ enum {\n \tPROP_AUTO_FOCUS_MODE,\n };\n \n+static void gst_libcamera_src_child_proxy_init(gpointer g_iface,\n+\t\t\t\t\t       gpointer iface_data);\n+\n G_DEFINE_TYPE_WITH_CODE(GstLibcameraSrc, gst_libcamera_src, GST_TYPE_ELEMENT,\n+\t\t\tG_IMPLEMENT_INTERFACE(GST_TYPE_CHILD_PROXY,\n+\t\t\t\t\t      gst_libcamera_src_child_proxy_init)\n \t\t\tGST_DEBUG_CATEGORY_INIT(source_debug, \"libcamerasrc\", 0,\n \t\t\t\t\t\t\"libcamera Source\"))\n \n@@ -865,8 +870,10 @@ gst_libcamera_src_init(GstLibcameraSrc *self)\n \n \tg_mutex_init(&state->lock_);\n \n-\tstate->srcpads_.push_back(gst_pad_new_from_template(templ, \"src\"));\n-\tgst_element_add_pad(GST_ELEMENT(self), state->srcpads_.back());\n+\tGstPad *pad = gst_pad_new_from_template(templ, \"src\");\n+\tstate->srcpads_.push_back(pad);\n+\tgst_element_add_pad(GST_ELEMENT(self), pad);\n+\tgst_child_proxy_child_added(GST_CHILD_PROXY(self), G_OBJECT(pad), GST_OBJECT_NAME(pad));\n \n \tGST_OBJECT_FLAG_SET(self, GST_ELEMENT_FLAG_SOURCE);\n \n@@ -897,6 +904,8 @@ gst_libcamera_src_request_new_pad(GstElement *element, GstPadTemplate *templ,\n \t\treturn NULL;\n \t}\n \n+\tgst_child_proxy_child_added(GST_CHILD_PROXY(self), G_OBJECT(pad), GST_OBJECT_NAME(pad));\n+\n \treturn reinterpret_cast<GstPad *>(g_steal_pointer(&pad));\n }\n \n@@ -905,6 +914,8 @@ gst_libcamera_src_release_pad(GstElement *element, GstPad *pad)\n {\n \tGstLibcameraSrc *self = GST_LIBCAMERA_SRC(element);\n \n+\tgst_child_proxy_child_removed(GST_CHILD_PROXY(self), G_OBJECT(pad), GST_OBJECT_NAME(pad));\n+\n \tGST_DEBUG_OBJECT(self, \"Pad %\" GST_PTR_FORMAT \" being released\", pad);\n \n \t{\n@@ -965,3 +976,33 @@ gst_libcamera_src_class_init(GstLibcameraSrcClass *klass)\n \t\t\t\t G_PARAM_WRITABLE);\n \tg_object_class_install_property(object_class, PROP_AUTO_FOCUS_MODE, spec);\n }\n+\n+/* GstChildProxy implementation */\n+static GObject *\n+gst_libcamera_src_child_proxy_get_child_by_index(GstChildProxy *child_proxy,\n+\t\t\t\t\t\t guint index)\n+{\n+\tGLibLocker lock(GST_OBJECT(child_proxy));\n+\tGObject *obj = nullptr;\n+\n+\tobj = reinterpret_cast<GObject *>(g_list_nth_data(GST_ELEMENT(child_proxy)->srcpads, index));\n+\tif (obj)\n+\t\tgst_object_ref(obj);\n+\n+\treturn obj;\n+}\n+\n+static guint\n+gst_libcamera_src_child_proxy_get_children_count(GstChildProxy *child_proxy)\n+{\n+\tGLibLocker lock(GST_OBJECT(child_proxy));\n+\treturn GST_ELEMENT_CAST(child_proxy)->numsrcpads;\n+}\n+\n+static void\n+gst_libcamera_src_child_proxy_init(gpointer g_iface, [[maybe_unused]] gpointer iface_data)\n+{\n+\tGstChildProxyInterface *iface = reinterpret_cast<GstChildProxyInterface *>(g_iface);\n+\tiface->get_child_by_index = gst_libcamera_src_child_proxy_get_child_by_index;\n+\tiface->get_children_count = gst_libcamera_src_child_proxy_get_children_count;\n+}\n","prefixes":["v2","1/2"]}