[{"id":29602,"web_url":"https://patchwork.libcamera.org/comment/29602/","msgid":"<171641938733.2920551.3037371029952944068@ping.linuxembedded.co.uk>","date":"2024-05-22T23:09:47","subject":"Re: [PATCH v1 1/2] gst: Add child proxy support to libcamerasrc","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Nicolas Dufresne (2024-05-22 21:39:23)\n> From: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n> \n> The child proxy interface is needed in order to allow setting\n> properties on pad using parse launch syntax.\n> \n\nI don't know anything about child proxies - so my review here is quite\nsuperficial - but from my perspective this is your code so you know best\n;-)\n\n\n> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n> ---\n>  src/gstreamer/gstlibcamerasrc.cpp | 45 +++++++++++++++++++++++++++++--\n>  1 file changed, 43 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\n> index 6a95b6af..74b372f3 100644\n> --- a/src/gstreamer/gstlibcamerasrc.cpp\n> +++ b/src/gstreamer/gstlibcamerasrc.cpp\n> @@ -157,7 +157,12 @@ enum {\n>         PROP_AUTO_FOCUS_MODE,\n>  };\n>  \n> +static void gst_libcamera_src_child_proxy_init(gpointer g_iface,\n> +                                              gpointer iface_data);\n> +\n>  G_DEFINE_TYPE_WITH_CODE(GstLibcameraSrc, gst_libcamera_src, GST_TYPE_ELEMENT,\n> +                       G_IMPLEMENT_INTERFACE(GST_TYPE_CHILD_PROXY,\n> +                                             gst_libcamera_src_child_proxy_init)\n>                         GST_DEBUG_CATEGORY_INIT(source_debug, \"libcamerasrc\", 0,\n>                                                 \"libcamera Source\"))\n>  \n> @@ -864,8 +869,10 @@ gst_libcamera_src_init(GstLibcameraSrc *self)\n>  \n>         g_mutex_init(&state->lock_);\n>  \n> -       state->srcpads_.push_back(gst_pad_new_from_template(templ, \"src\"));\n> -       gst_element_add_pad(GST_ELEMENT(self), state->srcpads_.back());\n> +       GstPad *pad = gst_pad_new_from_template(templ, \"src\");\n> +       state->srcpads_.push_back(pad);\n> +       gst_element_add_pad(GST_ELEMENT(self), pad);\n> +       gst_child_proxy_child_added(GST_CHILD_PROXY(self), G_OBJECT(pad), GST_OBJECT_NAME(pad));\n>  \n>         GST_OBJECT_FLAG_SET(self, GST_ELEMENT_FLAG_SOURCE);\n>  \n> @@ -896,6 +903,8 @@ gst_libcamera_src_request_new_pad(GstElement *element, GstPadTemplate *templ,\n>                 return NULL;\n>         }\n>  \n> +       gst_child_proxy_child_added(GST_CHILD_PROXY(self), G_OBJECT(pad), GST_OBJECT_NAME(pad));\n> +\n>         return reinterpret_cast<GstPad *>(g_steal_pointer(&pad));\n>  }\n>  \n> @@ -904,6 +913,8 @@ gst_libcamera_src_release_pad(GstElement *element, GstPad *pad)\n>  {\n>         GstLibcameraSrc *self = GST_LIBCAMERA_SRC(element);\n>  \n> +       gst_child_proxy_child_removed(GST_CHILD_PROXY(self), G_OBJECT(pad), GST_OBJECT_NAME(pad));\n> +\n>         GST_DEBUG_OBJECT(self, \"Pad %\" GST_PTR_FORMAT \" being released\", pad);\n>  \n>         {\n> @@ -964,3 +975,33 @@ gst_libcamera_src_class_init(GstLibcameraSrcClass *klass)\n>                                  G_PARAM_WRITABLE);\n>         g_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> +                                                guint index)\n> +{\n> +       GLibLocker lock(GST_OBJECT(child_proxy));\n> +       GObject *obj = nullptr;\n> +\n> +       obj = reinterpret_cast<GObject*>(g_list_nth_data(GST_ELEMENT(child_proxy)->srcpads, index));\n> +       if (obj)\n> +               gst_object_ref(obj);\n> +\n> +       return obj;\n> +}\n> +\n> +static guint\n> +gst_libcamera_src_child_proxy_get_children_count(GstChildProxy * child_proxy)\n> +{\n> +       GLibLocker lock(GST_OBJECT(child_proxy));\n> +       return 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> +  GstChildProxyInterface *iface = reinterpret_cast<GstChildProxyInterface *>(g_iface);\n> +  iface->get_child_by_index = gst_libcamera_src_child_proxy_get_child_by_index;\n> +  iface->get_children_count = gst_libcamera_src_child_proxy_get_children_count;\n\nabsolute minor nit: The indentation here is less than the other\nfunctions.\n\nIf that's all I can come up with :\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> +}\n> -- \n> 2.45.0\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 43805BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 May 2024 23:09:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AB07F63499;\n\tThu, 23 May 2024 01:09:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CDC2263498\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 May 2024 01:09:50 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C8CE97E1;\n\tThu, 23 May 2024 01:09:37 +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=\"TtM45xU9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1716419377;\n\tbh=VTvhgpyfJmfLEsA9EJ1ymFzloVsqmMOF3sEIhuC0Bss=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=TtM45xU9MAKL0xajOW2lTczqPCwSvHfZ2L8HPZTaKDt8SGVFk5oyQ2MvfsDIBTgIr\n\tMb+8amzHSo/cgcuooQwHapvldEQMKl8SwKpOGFyxUmfYoSf2/QXT+oVHKvP9H2jQgW\n\tSjAidc5xKV3CAEYo4CMx1U1omr+/lFA4dqACFK7M=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240522203924.1111388-2-nicolas@ndufresne.ca>","References":"<20240522203924.1111388-1-nicolas@ndufresne.ca>\n\t<20240522203924.1111388-2-nicolas@ndufresne.ca>","Subject":"Re: [PATCH v1 1/2] gst: Add child proxy support to libcamerasrc","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Nicolas Dufresne <nicolas.dufresne@collabora.com>","To":"Nicolas Dufresne <nicolas@ndufresne.ca>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 23 May 2024 00:09:47 +0100","Message-ID":"<171641938733.2920551.3037371029952944068@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]