Patch Detail
Show a patch.
GET /api/patches/16352/?format=api
{ "id": 16352, "url": "https://patchwork.libcamera.org/api/patches/16352/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16352/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20220623232210.18742-6-laurent.pinchart@ideasonboard.com>", "date": "2022-06-23T23:22:02", "name": "[libcamera-devel,05/13] gstreamer: Move timestamp calculation out of pad loop", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "ea5caf5278b9864c73b3b744c7a34daf8af3e200", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16352/mbox/", "series": [ { "id": 3214, "url": "https://patchwork.libcamera.org/api/series/3214/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3214", "date": "2022-06-23T23:21:57", "name": "gstreamer: Queue multiple requests", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3214/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16352/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16352/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 64415BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Jun 2022 23:22:40 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E3E8E65647;\n\tFri, 24 Jun 2022 01:22:39 +0200 (CEST)", "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 2CFAC6563F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jun 2022 01:22:31 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A194D6BB;\n\tFri, 24 Jun 2022 01:22:30 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656026560;\n\tbh=O+zsmWCvcUzybHHKyq6uNTXMTa+3F2tPx2/ZWbHTpcs=;\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=v9CiollwtBjuwamR1X0X9XD+qO5QP93Q1L2nUn2D5s1MiqXqMdG9FA8KAkAMmxCYU\n\tQBy94z/G5iZk1a/qQjX4OAJguJbItx8rrmeGD0BdMI17nY9ouzY6Vt22h5QgBsitz+\n\tQb67lBGnSJ4NreO3XECUpHffEnSL4EWxxrhW5FP5mPZKL+1846cH2ZZuO/F+JqFdrJ\n\t1jpc2P8Fh9xIomcbwde80NnFv8a5byyt8xXNKwBiNnN6SUiaXw4TuiM4HvLiUDjvLg\n\tojzZQyIBt4ZpIjwhpqjk+tC/wcePpOg2wKHyA5sj8BxTxPk8eOZNkAVq02rd7upZPo\n\tKNTTmgwqXmgRg==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656026550;\n\tbh=O+zsmWCvcUzybHHKyq6uNTXMTa+3F2tPx2/ZWbHTpcs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=DmVz0yjJ1/utX6080k557Z0GBlSJO5loPh3kKKkD178sVx6aCWZeAAIRXVVBJZQEs\n\ttq9PeqqTWT7MiOigbyff8azvsIRyIBWZFkxyZEBKBMJskmSQS8BnORlFKfjpt9d6Fz\n\tC3VSwKRGmBggnwchY7i33Hql/zPB2ErK2s9Ecsts=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"DmVz0yjJ\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 24 Jun 2022 02:22:02 +0300", "Message-Id": "<20220623232210.18742-6-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20220623232210.18742-1-laurent.pinchart@ideasonboard.com>", "References": "<20220623232210.18742-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 05/13] gstreamer: Move timestamp\n\tcalculation out of pad loop", "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": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "Cc": "Nicolas Dufresne <nicolas.dufresne@collabora.com>,\n\tVedant Paranjape <vedantparanjape160201@gmail.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The buffer pts and the pad latency are computed from the framebuffer\ntimestamp, separately for each pad. Use the sensor timestamp provided\nthrough the request metadata instead, to compute the values once outside\nof the pads loop.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/gstreamer/gstlibcamerasrc.cpp | 34 ++++++++++++++++++++++---------\n 1 file changed, 24 insertions(+), 10 deletions(-)", "diff": "diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex 700bee2bf877..a1fab71d4f09 100644\n--- a/src/gstreamer/gstlibcamerasrc.cpp\n+++ b/src/gstreamer/gstlibcamerasrc.cpp\n@@ -34,6 +34,7 @@\n \n #include <libcamera/camera.h>\n #include <libcamera/camera_manager.h>\n+#include <libcamera/control_ids.h>\n \n #include <gst/base/base.h>\n \n@@ -164,22 +165,35 @@ GstLibcameraSrcState::requestCompleted(Request *request)\n \t\treturn;\n \t}\n \n+\tGstClockTime latency;\n+\tGstClockTime pts;\n+\n+\tif (GST_ELEMENT_CLOCK(src_)) {\n+\t\tint64_t timestamp = request->metadata().get(controls::SensorTimestamp);\n+\n+\t\tGstClockTime gst_base_time = GST_ELEMENT(src_)->base_time;\n+\t\tGstClockTime gst_now = gst_clock_get_time(GST_ELEMENT_CLOCK(src_));\n+\t\t/* \\todo Need to expose which reference clock the timestamp relates to. */\n+\t\tGstClockTime sys_now = g_get_monotonic_time() * 1000;\n+\n+\t\t/* Deduced from: sys_now - sys_base_time == gst_now - gst_base_time */\n+\t\tGstClockTime sys_base_time = sys_now - (gst_now - gst_base_time);\n+\t\tpts = timestamp - sys_base_time;\n+\t\tlatency = sys_now - timestamp;\n+\t} else {\n+\t\tlatency = 0;\n+\t\tpts = 0;\n+\t}\n+\n \tfor (GstPad *srcpad : srcpads_) {\n \t\tStream *stream = gst_libcamera_pad_get_stream(srcpad);\n \t\tGstBuffer *buffer = wrap->detachBuffer(stream);\n \n \t\tFrameBuffer *fb = gst_libcamera_buffer_get_frame_buffer(buffer);\n \n-\t\tif (GST_ELEMENT_CLOCK(src_)) {\n-\t\t\tGstClockTime gst_base_time = GST_ELEMENT(src_)->base_time;\n-\t\t\tGstClockTime gst_now = gst_clock_get_time(GST_ELEMENT_CLOCK(src_));\n-\t\t\t/* \\todo Need to expose which reference clock the timestamp relates to. */\n-\t\t\tGstClockTime sys_now = g_get_monotonic_time() * 1000;\n-\n-\t\t\t/* Deduced from: sys_now - sys_base_time == gst_now - gst_base_time */\n-\t\t\tGstClockTime sys_base_time = sys_now - (gst_now - gst_base_time);\n-\t\t\tGST_BUFFER_PTS(buffer) = fb->metadata().timestamp - sys_base_time;\n-\t\t\tgst_libcamera_pad_set_latency(srcpad, sys_now - fb->metadata().timestamp);\n+\t\tif (pts) {\n+\t\t\tGST_BUFFER_PTS(buffer) = pts;\n+\t\t\tgst_libcamera_pad_set_latency(srcpad, latency);\n \t\t} else {\n \t\t\tGST_BUFFER_PTS(buffer) = 0;\n \t\t}\n", "prefixes": [ "libcamera-devel", "05/13" ] }