Show a patch.

GET /api/patches/16441/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 16441,
    "url": "https://patchwork.libcamera.org/api/patches/16441/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16441/",
    "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": "<20220630000251.31295-5-laurent.pinchart@ideasonboard.com>",
    "date": "2022-06-30T00:02:43",
    "name": "[libcamera-devel,v2,04/12] gstreamer: Move timestamp calculation out of pad loop",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "72cf6f06cf465b308e4f80fc2e2d5ea84e1a03de",
    "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/16441/mbox/",
    "series": [
        {
            "id": 3234,
            "url": "https://patchwork.libcamera.org/api/series/3234/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3234",
            "date": "2022-06-30T00:02:39",
            "name": "gstreamer: Queue multiple requests",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3234/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16441/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16441/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 AD4CFBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jun 2022 00:03:26 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2D9716564D;\n\tThu, 30 Jun 2022 02:03:26 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C3E5D6563E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jun 2022 02:03:16 +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 5D67059D;\n\tThu, 30 Jun 2022 02:03:16 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656547406;\n\tbh=QuupnKHlYQE/5OxuJDMjEmlGrudsBuJBHh3NT/jjrOM=;\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=BZlD44eRDOsslesKRGJpceMrsuy3O4//Z/eaqh2zqhNTa28SLCkX0NswTV2+ETDjs\n\tMq3z7OLJoA59acv2t+9zQtjtsVIdjkRNArxhjQE//Gzf+dgBZSxL+L/krCE8+etBfA\n\tQNp4Xwskjf8O/dk/rk+fEsqnZL5ji7kgdb6Z6WtxxMSlNaEmcgCt9mVarFoueoUGfU\n\tenKay1OSgbQEjw97ozW1XVUCm2M//2/blSYDjokWevvzzNpcLoMRRDGsRWK7pBQxoT\n\tJ+rdPngPbQtz2aRwSjgY0B7c/+2NP5s00Uai/NfC1+IR+cxrLpVLNktSoA8m6MmakV\n\tvQP6aqI0oX0rA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656547396;\n\tbh=QuupnKHlYQE/5OxuJDMjEmlGrudsBuJBHh3NT/jjrOM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=I7B36/r8xycPeCxeOrhADTG4WrI0BnkKDiJzOR3BrUxXfeVyjLw8feiOINqOhzwPX\n\tPDiNaOar6kVlPDcse7kh4L1WUwjnUszmsXrkUqZLImNU/BldsH4HASHaDHOaSWI+As\n\t3Fe69mXqSdLTgd0JJE/rC/Mke/YrD25ZZ9ztW+3Q="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"I7B36/r8\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 30 Jun 2022 03:02:43 +0300",
        "Message-Id": "<20220630000251.31295-5-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.35.1",
        "In-Reply-To": "<20220630000251.31295-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20220630000251.31295-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 04/12] 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>",
        "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>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n---\nChanges since v1:\n\n- Use GST_CLOCK_TIME_NONE and GST_CLOCK_TIME_IS_VALID()\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..37f201e89828 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 = GST_CLOCK_TIME_NONE;\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 (GST_CLOCK_TIME_IS_VALID(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",
        "v2",
        "04/12"
    ]
}