Patch Detail
Show a patch.
GET /api/1.1/patches/19229/?format=api
{ "id": 19229, "url": "https://patchwork.libcamera.org/api/1.1/patches/19229/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19229/", "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": "<20231123044811.70703-3-umang.jain@ideasonboard.com>", "date": "2023-11-23T04:48:11", "name": "[libcamera-devel,v4,2/2] gstreamer: Implement element EOS handling", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "98aacd38bcfa0484066c7b1987e323b12179e12a", "submitter": { "id": 86, "url": "https://patchwork.libcamera.org/api/1.1/people/86/?format=api", "name": "Umang Jain", "email": "umang.jain@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19229/mbox/", "series": [ { "id": 4081, "url": "https://patchwork.libcamera.org/api/1.1/series/4081/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4081", "date": "2023-11-23T04:48:09", "name": "gstreamer: Fix EOS clang build breakage", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4081/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19229/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19229/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 006E5C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Nov 2023 04:48:25 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9E187629C3;\n\tThu, 23 Nov 2023 05:48:25 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A6B96629BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Nov 2023 05:48:23 +0100 (CET)", "from umang.jainideasonboard.com (unknown [103.251.226.72])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B0E4B749;\n\tThu, 23 Nov 2023 05:47:50 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1700714905;\n\tbh=oKNmoe5uIoMBAVhKJcFrgWVMNFo1cN2vM+RAbJZgy0U=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=f2Nb7r/raJNfmiA6AA44e0sZIe6V+kIu7XGuzRntYGqy5hWAamW0iQ7pjzT9Oy28F\n\tIloFk2OBXeejfLVPmt7rZMZVcP3OPFfTTbBiF4ZQXEk6H0KogvQnkT88g/ByNHjI3W\n\tKmUGls+HPxpfDxSb7vuC98CUrGTwo+J3XYBfWMRtDSXo5tHb3Z3htYCCdvomZbW89t\n\t2E/LyrDITPHjcb7rZCvzLBfKGRbtghZ1ug2vfO8Yi9YN5HNUIKpXVjNqgn5ykr2zRO\n\tv+xqrYsHvZru6/lFq3RSyeP+FSvzgR+qmOOE6Je+hp2/+Pj1+vXmfLt6qgZhlFSwH/\n\to3IjOiOJMtVnA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1700714872;\n\tbh=oKNmoe5uIoMBAVhKJcFrgWVMNFo1cN2vM+RAbJZgy0U=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=P6Xa/65+JAL6bvVC5TuJihoe8DPbwy/3Glas4oBscMbyWWMDrDO/Hcmk6z1UwgNlZ\n\tuk87jzT0Zh5yQQVUBSHpId2fLVQQK+pLEyIIthj/fkqWpb04Rr9kT8t27KJuXsmdaW\n\t5tGCbMvg4yjj+usaSSerQ8hxcUvZCLzlKomVR8xc=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"P6Xa/65+\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 23 Nov 2023 10:18:11 +0530", "Message-Id": "<20231123044811.70703-3-umang.jain@ideasonboard.com>", "X-Mailer": "git-send-email 2.40.1", "In-Reply-To": "<20231123044811.70703-1-umang.jain@ideasonboard.com>", "References": "<20231123044811.70703-1-umang.jain@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 2/2] 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": "Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Umang Jain <umang.jain@ideasonboard.com>", "Cc": "Nicolas Dufresne <nicolas.dufresne@collabora.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Jaslo Ziska <jaslo@ziska.de>\n\nThis 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. This in turn enables libcamerasrc\nto receive EOS events, for example, from gst-launch-1.0 with\nthe -e (--eos-on-shutdown) flag applied.\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>\nReviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\nChanges in v4:\n- Fix clang build false-positive compile breakage\n Use gst_clear_event(&oldEvent) to free oldEvent.\n---\n\n src/gstreamer/gstlibcamerasrc.cpp | 37 ++++++++++++++++++++++++++++++-\n 1 file changed, 36 insertions(+), 1 deletion(-)", "diff": "diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex 63d99571..fde1065d 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,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\tGstEvent *oldEvent = self->pending_eos.exchange(event);\n+\t\tgst_clear_event(&oldEvent);\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", "v4", "2/2" ] }