Patch Detail
Show a patch.
GET /api/1.1/patches/19213/?format=api
{ "id": 19213, "url": "https://patchwork.libcamera.org/api/1.1/patches/19213/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19213/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20231114122800.10007-1-jaslo@ziska.de>", "date": "2023-11-14T12:18:57", "name": "[libcamera-devel,v3] gstreamer: Implement element EOS handling", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "2421fb5c9866c2c3173578114683a915a83b0675", "submitter": { "id": 173, "url": "https://patchwork.libcamera.org/api/1.1/people/173/?format=api", "name": "Jaslo Ziska", "email": "jaslo@ziska.de" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19213/mbox/", "series": [ { "id": 4075, "url": "https://patchwork.libcamera.org/api/1.1/series/4075/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4075", "date": "2023-11-14T12:18:57", "name": "[libcamera-devel,v3] gstreamer: Implement element EOS handling", "version": 3, "mbox": "https://patchwork.libcamera.org/series/4075/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19213/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19213/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 6833DC3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Nov 2023 12:29:20 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AFB65629BC;\n\tTue, 14 Nov 2023 13:29:19 +0100 (CET)", "from mo4-p00-ob.smtp.rzone.de (mo4-p00-ob.smtp.rzone.de\n\t[81.169.146.220])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 52DE56299E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Nov 2023 13:29:18 +0100 (CET)", "from archlinux.fritz.box by smtp.strato.de (RZmta 49.9.1 AUTH)\n\twith ESMTPSA id j3f4eezAECTG5AV\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits))\n\t(Client did not present a certificate);\n\tTue, 14 Nov 2023 13:29:16 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1699964959;\n\tbh=37kERtv048rb2gEwBd/vbzTSMW6IfaZv6J7FWmc+cX4=;\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=uzOdLAlTdweX9KGXEkz6PMUHtD0lSIQpBqICjAYXGDhQEQDLSnJg24GKmbXt9CFvD\n\toISyEhmYMu2/OchLREf7HxJhihvmmQ350VKVjbwt2ycGTGiByp8VzNL+0hyTRsHxSG\n\t8ghxNVlRViJ06TPai6pG0xosYmLKg1cZQneEY8Hh+tJYfpO5EFHFc7BBTB50QmLOsc\n\tTZDuUGEpiotNzN0nB3sm5C1yxjisZgDc5UQRDrMbCGpJZiwrnS+WVcsLqzH4HI+cVI\n\tBzr+Zzhqe/qR3JHPpKJW1h2DcM3aacGzSC3hTAFBVldLmK0zbNd5WcYbscKruP8LZo\n\tDHFbO5Yy7fpNg==", "v=1; a=rsa-sha256; c=relaxed/relaxed; t=1699964956;\n\ts=strato-dkim-0002; d=ziska.de;\n\th=Message-ID:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender;\n\tbh=pxDXlX0pFgep9WKfoOsj0HSKbBG9gmNbPQrgEOZ5nSA=;\n\tb=Fq3pFej2C9qZwx1Iz3lf7DelgEdbfWPSN+TkMiC1rQUu5DodTtBpTX0xu8Y07ESPDH\n\tzbHZJy1PXVd5M2FNtCxKfCGw9k1cxrALg9sxZPER2YI6jnzA29yipdTBMXmL9TxoQUaQ\n\tx64kbPubcF2V8GifpFOHzlhax4rcuXbCVaVjnWMjd1gmkR9ZSBu3VR2s51LI04Hr+plH\n\tY1wlr02Ig4xkiOrb1SkZfHgsJBWu9f+RXYG8hw5EiQ4GbaI0vKgIpsYMBHEHeEU3qkLW\n\ts/gN+ofjWRgda4wK0h4Bjc+shj/107GLnIhoPnkNhYhcYn2udEBr86FqxjHN0M5OJ9ed\n\tHIZA==", "v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1699964956;\n\ts=strato-dkim-0003; d=ziska.de;\n\th=Message-ID:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender;\n\tbh=pxDXlX0pFgep9WKfoOsj0HSKbBG9gmNbPQrgEOZ5nSA=;\n\tb=NK0KJuCFyrCM4AhnYhuUHEvWbwAWg1VnQctLhwOs7HAr78NcTkCBvDK/OYxqYSICBL\n\tlV+geDnfyT/RaWlBwNDA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=ziska.de header.i=@ziska.de\n\theader.b=\"Fq3pFej2\"; \n\tdkim=permerror (0-bit key) header.d=ziska.de header.i=@ziska.de\n\theader.b=\"NK0KJuCF\"; dkim-atps=neutral", "ARC-Seal": "i=1; a=rsa-sha256; t=1699964956; cv=none;\n\td=strato.com; s=strato-dkim-0002;\n\tb=fs8eisYuPMlY0uLic695Q3FKsBGRyiKBVUici0SOKLKUQNlpe+CRythe6pB7YqG1Lv\n\tGj2xjeXT+3j0An9Rok+H5jTzVjia9XNvhnvj8X1e4O+9xLGwjAz6z0w/KEZk4WoaKFyX\n\tvHZf2JZ2/7zKFGE096nCYBZsQ21J5Xr0nddTICdS+YLQGR5ll277TSLMMMp0pnVMvOvF\n\tZC6JS/3KuBbumgD+/ROE5ldhehGmPPSR+Y3u9WSKKYPLEDnyQ0NWvbmPQHBlHpd269pV\n\tvGSDq9hHCjIMnq6Iz4IFjSkjCi0KotRQQXAhTRW1NkdIoaPG0m20YoXIx8W/qNaRPpdQ\n\tqZ3g==", "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; t=1699964956;\n\ts=strato-dkim-0002; d=strato.com;\n\th=Message-ID:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender;\n\tbh=pxDXlX0pFgep9WKfoOsj0HSKbBG9gmNbPQrgEOZ5nSA=;\n\tb=h1g/OlPaXzAPz+CXcCIQDuHIYvwwsAAKkQbsDC9pJW3Y5+bR7/AAkIi/UGoBWAudM3\n\tb5936UPSlP2JJog1lvt+6Y6VRrCzoGizv26SgbjEJF2i+D/TW150kfiH0vnZLQhAOPHv\n\tWFM7ffAMv9xGMDgLUeULN2ki5+eDq20NYAAufd5gsfwYdzh9AvMtNgShtPitxYihkNET\n\tTMykQloPgr/QFy0GS+Nvj1Dd41biNpd5Drz6XALduIptNtN1M6P+wxLn0Mpq3HSalYAV\n\tTYPXwONXZtgBFdkzQPg+mv9zQcY6bT9Y/e8WunppdSiLqWM6tWemQEBNrV+RFCcs3Hb4\n\taTWg==", "ARC-Authentication-Results": "i=1; strato.com;\n arc=none;\n dkim=none", "X-RZG-CLASS-ID": "mo00", "X-RZG-AUTH": "\":Jm0XeU+IYfb0x77LHmrjN5Wlb7TBwusDqIM6Hizy8VdfzvKi4yoFC9cCgorrBfJa1Ew82pWz/tz8/A+0LafdQ1JRlSvq\"", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 14 Nov 2023 13:18:57 +0100", "Message-ID": "<20231114122800.10007-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 v3] 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": "This commit implements EOS handling for events sent to the libcamerasrc\nelement by the send_event method (which can happen when pressing\nCtrl-C while running gst-launch-1.0 -e, see below). EOS events from\ndownstream elements returning GST_FLOW_EOS are not considered here.\n\nTo archive this add a function for the send_event method which handles\nthe GST_EVENT_EOS event. This function will set an atomic to the\nreceived event and push this EOS event to all source pads in the running\ntask.\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\nBug: https://bugs.libcamera.org/show_bug.cgi?id=91\nSigned-off-by: Jaslo Ziska <jaslo@ziska.de>\nAcked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\n---\nThanks for all the advise on v2 everyone!\n\nIn this revision I explain which EOS events are handled in the commit message a little bit more and link to the bug report.\n\nAs recommended, g_autoptr is now used. I decided to declare g_autoptr(event) outside of the if-statement for now, I was not sure what the consensus on this is at the moment.\n\nRegards,\n\nJaslo\n\n src/gstreamer/gstlibcamerasrc.cpp | 36 ++++++++++++++++++++++++++++++-\n 1 file changed, 35 insertions(+), 1 deletion(-)\n\n--\n2.42.1", "diff": "diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex 63d99571..767017db 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+\tg_autoptr(GstEvent) event = self->pending_eos.exchange(nullptr);\n+\tif (event) {\n+\t\tfor (GstPad *srcpad : state->srcpads_)\n+\t\t\tgst_pad_push_event(srcpad, gst_event_ref(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,27 @@ 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\tg_autoptr(GstEvent) oldEvent = self->pending_eos.exchange(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 +810,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 +877,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", "v3" ] }