{"id":19199,"url":"https://patchwork.libcamera.org/api/patches/19199/?format=json","web_url":"https://patchwork.libcamera.org/patch/19199/","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":"<20231110121133.17950-1-jaslo@ziska.de>","date":"2023-11-10T12:07:29","name":"[libcamera-devel,v2] gstreamer: Implement element EOS handling","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"f7dc923d6a46f1445e28e46e77c3890c7df37108","submitter":{"id":173,"url":"https://patchwork.libcamera.org/api/people/173/?format=json","name":"Jaslo Ziska","email":"jaslo@ziska.de"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19199/mbox/","series":[{"id":4069,"url":"https://patchwork.libcamera.org/api/series/4069/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4069","date":"2023-11-10T12:07:29","name":"[libcamera-devel,v2] gstreamer: Implement element EOS handling","version":2,"mbox":"https://patchwork.libcamera.org/series/4069/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19199/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19199/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 73AA1BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Nov 2023 12:12:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AC9E3629AB;\n\tFri, 10 Nov 2023 13:12:49 +0100 (CET)","from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de\n\t[81.169.146.163])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 60D6C61DB6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Nov 2023 13:12:48 +0100 (CET)","from archlinux.fritz.box by smtp.strato.de (RZmta 49.9.1 AUTH)\n\twith ESMTPSA id 6bb150zAACCl9JT\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits))\n\t(Client did not present a certificate);\n\tFri, 10 Nov 2023 13:12:47 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1699618369;\n\tbh=8SHAyFth/9eDDb4vHkh8QH16SbUAiglJBG9nQMr6o6Q=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=d/pD9DlhWh/f/jhVRJG2E0ZXuxmKFhe2KBU9NFUAW+Q9/9TfXlM+fAPfMF0pIpnrM\n\tG0p2f2Z3wUZAAGIbEU/4RAE82b7dRb+/tITUzTERFN599OyxzdrLdZsjt9DuuKMAsf\n\tsVMdcKhUJY8X8kH/M1/zmTcyTDdBSGMePV7MqSk98sXjn1fVJbCb8LdVa5f5WWkPEb\n\ttnjRt+FPeweXgojOrXrznoZ6/oHYdEWQ2uzlNUQMcYgJhNe1BbDa1+V6ybJYu3ubl6\n\taKL5xSKrBK6YWHfgsmveTcnKRVAfb7ZuWbQs9l3yn67YVWZ1knIwQZ2HO7nhuqeeCi\n\tqSojaYKB6vrBw==","v=1; a=rsa-sha256; c=relaxed/relaxed; t=1699618367;\n\ts=strato-dkim-0002; d=ziska.de;\n\th=Message-ID:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender;\n\tbh=ohOq1RSR+oWI9FuID15YxNed9LRYarY/PID8hAP0o5U=;\n\tb=FNCXnPTrLpWJIa5/g3Zth8nmWIyz88CNjwxcl2C6jZP50Ir5OTwhNFkHlmuUB8fZc4\n\tRDX2GUF5JxYLjLA2iRrcMt6Q614xG3nmDHxkeNLrxIHYYlhUh/ek7BdVHlYhvm7Y4Mrx\n\tOHDPzoCx43sTUWVsZvdCZEbuI15o5W+qpEf8fH5le/4GZRpdoc0igSqvFHv1cLdBlzL3\n\tcXsI/F/r7ibdQVsv4jdv8wCusPUn/IzV67/6UOPhnxwh20unBcWnaMxn8dlCWT5ywltu\n\tF/UDtaHGl2Uz7nR9omzR1DCjlVI5aCpl0JEF9dO27GsuU+QUSDLI2iqfA40ZYgnzYMWa\n\twvYw==","v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1699618367;\n\ts=strato-dkim-0003; d=ziska.de;\n\th=Message-ID:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender;\n\tbh=ohOq1RSR+oWI9FuID15YxNed9LRYarY/PID8hAP0o5U=;\n\tb=l1jRZjNFn2U6zZg6drFa36Q+Y3s5TqH+8QwQekDDagK+9mP9lG7fItEMhevMhwxtzG\n\tK+utDzc+QLovfAIQzzBg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=ziska.de header.i=@ziska.de\n\theader.b=\"FNCXnPTr\"; \n\tdkim=permerror (0-bit key) header.d=ziska.de header.i=@ziska.de\n\theader.b=\"l1jRZjNF\"; dkim-atps=neutral","ARC-Seal":"i=1; a=rsa-sha256; t=1699618367; cv=none;\n\td=strato.com; s=strato-dkim-0002;\n\tb=HJsI3ctbD7ZF87q1f7Y+v87/f3nUZfrQ6XYrv0dRAj3H7jWvCh5yz6wdQTHcavdA2U\n\ti+nPp9nEFinS33FtoMyWfpWy0CBVv4YLY9HZ1rULpS7u28LfKoU1hY9sOiEJO8baw+Y7\n\tTbrLJL3v6+WlrEHU8Y2R87PtEHWXuY01/0JQRnCVqpMkl+XUQjd1up2s9pPulv2YOG0H\n\tZV1ZJHXuaEcg2eF7C9j2rmNksYFNyNIMyv4Az4pgB7dBGAmSl7AeHdFt3kI0gTqR3Pb7\n\tmT/p2cXqcPB/W8jLF2uXsvziSymRyEU88np15/4L/ZeS3Fghnz/AOVwk6njTHVp71TSL\n\tqGYA==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; t=1699618367;\n\ts=strato-dkim-0002; d=strato.com;\n\th=Message-ID:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender;\n\tbh=ohOq1RSR+oWI9FuID15YxNed9LRYarY/PID8hAP0o5U=;\n\tb=HNL3r6HO5TfBws6AqGJoZEzg9p3PC4+oNMo9hHl2c8Mp8UHLF1urm3aYYPMrQw4ta+\n\tnjrfZ2DHeVzBBt08a2NMeGA82+iM1uytBah4jQHm+tcZV9MPnWanIhM5WkUL2fVJIMAO\n\tEZFVgCR/8C2bkjcal4Ayo/ohLNXu7yiPAZvEyYvL4bJ37qNuhXbq6Mmo+7RAJvyIiuq0\n\ts553Vzyy8c5361Z76jVBrwUPafeEuOKX0t7Z2OjKUyrM02e7nBT8ckgPTahARepMqpKE\n\t+eeUiLpBeZQRpd25h5z2x4iHg08xhuJ0wAlvEnL4HscicFO+S9agdFAhMYgTqH5K+Xyt\n\t3Wqw==","ARC-Authentication-Results":"i=1; strato.com;\n    arc=none;\n    dkim=none","X-RZG-CLASS-ID":"mo00","X-RZG-AUTH":"\":Jm0XeU+IYfb0x77LHmrjN5Wlb7TBwusDqIM6Hizy8VdfzvKi4yoFC9cHhIq5B/Jayry4rG79lXjQgouSiQamHMjd97FH\"","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 10 Nov 2023 13:07:29 +0100","Message-ID":"<20231110121133.17950-1-jaslo@ziska.de>","X-Mailer":"git-send-email 2.42.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain; charset=\"us-ascii\"","Subject":"[libcamera-devel] [PATCH v2] gstreamer: Implement element EOS\n\thandling","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>","From":"Jaslo Ziska via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jaslo Ziska <jaslo@ziska.de>","Cc":"Jaslo Ziska <jaslo@ziska.de>,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a function for the send_event method which handles the GST_EVENT_EOS\nevent. This function will set an atomic to the received event and push\nthis EOS event to all source pads in the running task.\n\nAlso set the GST_ELEMENT_FLAG_SOURCE flag to identify libcamerasrc as a\nsource element which enables it to receive EOS events sent to the\n(pipeline) bin containing it.\nThis in turn enables libcamerasrc to for example receive EOS events from\ngst-launch-1.0 when using the -e flag.\n\nSigned-off-by: Jaslo Ziska <jaslo@ziska.de>\nAcked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n---\nUse std::atomic<GstEvent *> instead of glib_atomic_int_* plus a seperate GstEvent pointer and add a commit message.\n\n src/gstreamer/gstlibcamerasrc.cpp | 37 ++++++++++++++++++++++++++++++-\n 1 file changed, 36 insertions(+), 1 deletion(-)\n\n--\n2.42.1","diff":"diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex 63d99571..8e197956 100644\n--- a/src/gstreamer/gstlibcamerasrc.cpp\n+++ b/src/gstreamer/gstlibcamerasrc.cpp\n@@ -9,7 +9,6 @@\n /**\n  * \\todo The following is a list of items that needs implementation in the GStreamer plugin\n  *  - Implement GstElement::send_event\n- *    + Allowing application to send EOS\n  *    + Allowing application to use FLUSH/FLUSH_STOP\n  *    + Prevent the main thread from accessing streaming thread\n  *  - Implement renegotiation (even if slow)\n@@ -29,6 +28,7 @@\n\n #include \"gstlibcamerasrc.h\"\n\n+#include <atomic>\n #include <queue>\n #include <vector>\n\n@@ -144,6 +144,8 @@ struct _GstLibcameraSrc {\n \tgchar *camera_name;\n \tcontrols::AfModeEnum auto_focus_mode = controls::AfModeManual;\n\n+\tstd::atomic<GstEvent *> pending_eos;\n+\n \tGstLibcameraSrcState *state;\n \tGstLibcameraAllocator *allocator;\n \tGstFlowCombiner *flow_combiner;\n@@ -397,6 +399,14 @@ gst_libcamera_src_task_run(gpointer user_data)\n\n \tbool doResume = false;\n\n+\tif (GstEvent *event = self->pending_eos.exchange(nullptr)) {\n+\t\tfor (GstPad *srcpad : state->srcpads_)\n+\t\t\tgst_pad_push_event(srcpad, gst_event_ref(event));\n+\t\tgst_event_unref(event);\n+\n+\t\treturn;\n+\t}\n+\n \t/*\n \t * Create and queue one request. If no buffers are available the\n \t * function returns -ENOBUFS, which we ignore here as that's not a\n@@ -747,6 +757,28 @@ gst_libcamera_src_change_state(GstElement *element, GstStateChange transition)\n \treturn ret;\n }\n\n+static gboolean\n+gst_libcamera_src_send_event(GstElement *element, GstEvent *event)\n+{\n+\tGstLibcameraSrc *self = GST_LIBCAMERA_SRC(element);\n+\tgboolean ret = FALSE;\n+\n+\tswitch (GST_EVENT_TYPE(event)) {\n+\tcase GST_EVENT_EOS: {\n+\t\tif (GstEvent *old_event = self->pending_eos.exchange(event))\n+\t\t\tgst_event_unref(old_event);\n+\n+\t\tret = TRUE;\n+\t\tbreak;\n+\t}\n+\tdefault:\n+\t\tgst_event_unref(event);\n+\t\tbreak;\n+\t}\n+\n+\treturn ret;\n+}\n+\n static void\n gst_libcamera_src_finalize(GObject *object)\n {\n@@ -779,6 +811,8 @@ gst_libcamera_src_init(GstLibcameraSrc *self)\n \tstate->srcpads_.push_back(gst_pad_new_from_template(templ, \"src\"));\n \tgst_element_add_pad(GST_ELEMENT(self), state->srcpads_.back());\n\n+\tGST_OBJECT_FLAG_SET(self, GST_ELEMENT_FLAG_SOURCE);\n+\n \t/* C-style friend. */\n \tstate->src_ = self;\n \tself->state = state;\n@@ -844,6 +878,7 @@ gst_libcamera_src_class_init(GstLibcameraSrcClass *klass)\n \telement_class->request_new_pad = gst_libcamera_src_request_new_pad;\n \telement_class->release_pad = gst_libcamera_src_release_pad;\n \telement_class->change_state = gst_libcamera_src_change_state;\n+\telement_class->send_event = gst_libcamera_src_send_event;\n\n \tgst_element_class_set_metadata(element_class,\n \t\t\t\t       \"libcamera Source\", \"Source/Video\",\n","prefixes":["libcamera-devel","v2"]}