Show a patch.

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

{
    "id": 23463,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/23463/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23463/",
    "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": "<20250604130741.9228-3-laurent.pinchart@ideasonboard.com>",
    "date": "2025-06-04T13:07:36",
    "name": "[v2,2/7] gstreamer: Factor out video pool creation",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "ff85d6aa19a7b0987cbc717d257f29eb57a31fc4",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/23463/mbox/",
    "series": [
        {
            "id": 5204,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5204/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5204",
            "date": "2025-06-04T13:07:34",
            "name": "gstreamer: Miscellaneous cleanups + two fixes",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5204/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23463/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23463/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 7689BC3292\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  4 Jun 2025 13:08:01 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9092F68DC7;\n\tWed,  4 Jun 2025 15:07:58 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 84F5468DC1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Jun 2025 15:07:54 +0200 (CEST)",
            "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A126E9B;\n\tWed,  4 Jun 2025 15:07:51 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Xhbob2ib\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1749042471;\n\tbh=ZkDsFV+6zDls/l9g2PWIQ13Lo2Mw0xjgolYQ/ZsZ2Mk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Xhbob2ibEzLYIbQfekpclDa/DXt6Io3Da+OJoc34WiQd/afZflGqdp4i10Q2L+3dX\n\tVBISXS6z1noPdrZgkZDF26IQaAA/8k+o6NaahWOW8OT+fBvn91vhcnabVg2d0dIbj7\n\t5fIxZYmhwsAstqLaheTUaEVWj0jwG8qjKDtorxeU=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Hou Qi <qi.hou@nxp.com>,\n\tNicolas Dufresne <nicolas.dufresne@collabora.com>",
        "Subject": "[PATCH v2 2/7] gstreamer: Factor out video pool creation",
        "Date": "Wed,  4 Jun 2025 16:07:36 +0300",
        "Message-ID": "<20250604130741.9228-3-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.49.0",
        "In-Reply-To": "<20250604130741.9228-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20250604130741.9228-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The gst_libcamera_src_negotiate() function uses 5 identation levels,\ncausing long lines. Move video pool creation to a separate function to\nincrease readability.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v1:\n\n- Document the gst_libcamera_create_video_pool() function\n- Keep the gst_libcamera_extrapolate_info() call out of the new function\n- Reorder function arguments\n---\n src/gstreamer/gstlibcamerasrc.cpp | 114 +++++++++++++++++++-----------\n 1 file changed, 72 insertions(+), 42 deletions(-)\n\n--\nRegards,\n\nLaurent Pinchart",
    "diff": "diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex 6ede43b06a8a..79b94c7ee7c2 100644\n--- a/src/gstreamer/gstlibcamerasrc.cpp\n+++ b/src/gstreamer/gstlibcamerasrc.cpp\n@@ -29,6 +29,7 @@\n\n #include <atomic>\n #include <queue>\n+#include <tuple>\n #include <vector>\n\n #include <libcamera/camera.h>\n@@ -521,6 +522,72 @@ gst_libcamera_src_open(GstLibcameraSrc *self)\n \treturn true;\n }\n\n+/**\n+ * \\brief Create a video pool for a pad\n+ * \\param[in] self The libcamerasrc instance\n+ * \\param[in] srcpad The pad\n+ * \\param[in] caps The pad caps\n+ * \\param[in] info The video info for the pad\n+ *\n+ * This function creates and returns a video buffers pool for the given pad if\n+ * needed to accommodate stride mismatch. If the peer element supports the meta\n+ * API, the stride will be negotiated, and no pool if needed.\n+ *\n+ * \\return A tuple containing the video buffers pool pointer and an error code.\n+ * When no error occurs, the pool can be null if the peer element supports\n+ * stride negotiation.\n+ */\n+static std::tuple<GstBufferPool *, int>\n+gst_libcamera_create_video_pool(GstLibcameraSrc *self, GstPad *srcpad,\n+\t\t\t\tGstCaps *caps, const GstVideoInfo *info)\n+{\n+\tGstQuery *query = NULL;\n+\tconst gboolean need_pool = true;\n+\tgboolean has_video_meta = false;\n+\tGstBufferPool *video_pool = NULL;\n+\n+\tquery = gst_query_new_allocation(caps, need_pool);\n+\tif (!gst_pad_peer_query(srcpad, query))\n+\t\tGST_DEBUG_OBJECT(self, \"Didn't get downstream ALLOCATION hints\");\n+\telse\n+\t\thas_video_meta = gst_query_find_allocation_meta(query, GST_VIDEO_META_API_TYPE, NULL);\n+\n+\tif (!has_video_meta) {\n+\t\tGstBufferPool *pool = NULL;\n+\n+\t\tif (gst_query_get_n_allocation_pools(query) > 0)\n+\t\t\tgst_query_parse_nth_allocation_pool(query, 0, &pool, NULL, NULL, NULL);\n+\n+\t\tif (pool)\n+\t\t\tvideo_pool = pool;\n+\t\telse {\n+\t\t\tGstStructure *config;\n+\t\t\tguint min_buffers = 3;\n+\t\t\tvideo_pool = gst_video_buffer_pool_new();\n+\n+\t\t\tconfig = gst_buffer_pool_get_config(video_pool);\n+\t\t\tgst_buffer_pool_config_set_params(config, caps, info->size, min_buffers, 0);\n+\n+\t\t\tGST_DEBUG_OBJECT(self, \"Own pool config is %\" GST_PTR_FORMAT, config);\n+\n+\t\t\tgst_buffer_pool_set_config(GST_BUFFER_POOL_CAST(video_pool), config);\n+\t\t}\n+\n+\t\tGST_WARNING_OBJECT(self, \"Downstream doesn't support video meta, need to copy frame.\");\n+\n+\t\tif (!gst_buffer_pool_set_active(video_pool, true)) {\n+\t\t\tgst_caps_unref(caps);\n+\t\t\tGST_ELEMENT_ERROR(self, RESOURCE, SETTINGS,\n+\t\t\t\t\t  (\"Failed to active buffer pool\"),\n+\t\t\t\t\t  (\"gst_libcamera_src_negotiate() failed.\"));\n+\t\t\treturn { NULL, -EINVAL };\n+\t\t}\n+\t}\n+\n+\tgst_query_unref(query);\n+\treturn { video_pool, 0 };\n+}\n+\n /* Must be called with stream_lock held. */\n static bool\n gst_libcamera_src_negotiate(GstLibcameraSrc *self)\n@@ -603,50 +670,13 @@ gst_libcamera_src_negotiate(GstLibcameraSrc *self)\n \t\t/* Stride mismatch between camera stride and that calculated by video-info. */\n \t\tif (static_cast<unsigned int>(info.stride[0]) != stream_cfg.stride &&\n \t\t    GST_VIDEO_INFO_FORMAT(&info) != GST_VIDEO_FORMAT_ENCODED) {\n-\t\t\tGstQuery *query = NULL;\n-\t\t\tconst gboolean need_pool = true;\n-\t\t\tgboolean has_video_meta = false;\n-\n \t\t\tgst_libcamera_extrapolate_info(&info, stream_cfg.stride);\n\n-\t\t\tquery = gst_query_new_allocation(caps, need_pool);\n-\t\t\tif (!gst_pad_peer_query(srcpad, query))\n-\t\t\t\tGST_DEBUG_OBJECT(self, \"Didn't get downstream ALLOCATION hints\");\n-\t\t\telse\n-\t\t\t\thas_video_meta = gst_query_find_allocation_meta(query, GST_VIDEO_META_API_TYPE, NULL);\n-\n-\t\t\tif (!has_video_meta) {\n-\t\t\t\tGstBufferPool *pool = NULL;\n-\n-\t\t\t\tif (gst_query_get_n_allocation_pools(query) > 0)\n-\t\t\t\t\tgst_query_parse_nth_allocation_pool(query, 0, &pool, NULL, NULL, NULL);\n-\n-\t\t\t\tif (pool)\n-\t\t\t\t\tvideo_pool = pool;\n-\t\t\t\telse {\n-\t\t\t\t\tGstStructure *config;\n-\t\t\t\t\tguint min_buffers = 3;\n-\t\t\t\t\tvideo_pool = gst_video_buffer_pool_new();\n-\n-\t\t\t\t\tconfig = gst_buffer_pool_get_config(video_pool);\n-\t\t\t\t\tgst_buffer_pool_config_set_params(config, caps, info.size, min_buffers, 0);\n-\n-\t\t\t\t\tGST_DEBUG_OBJECT(self, \"Own pool config is %\" GST_PTR_FORMAT, config);\n-\n-\t\t\t\t\tgst_buffer_pool_set_config(GST_BUFFER_POOL_CAST(video_pool), config);\n-\t\t\t\t}\n-\n-\t\t\t\tGST_WARNING_OBJECT(self, \"Downstream doesn't support video meta, need to copy frame.\");\n-\n-\t\t\t\tif (!gst_buffer_pool_set_active(video_pool, true)) {\n-\t\t\t\t\tgst_caps_unref(caps);\n-\t\t\t\t\tGST_ELEMENT_ERROR(self, RESOURCE, SETTINGS,\n-\t\t\t\t\t\t\t  (\"Failed to active buffer pool\"),\n-\t\t\t\t\t\t\t  (\"gst_libcamera_src_negotiate() failed.\"));\n-\t\t\t\t\treturn false;\n-\t\t\t\t}\n-\t\t\t}\n-\t\t\tgst_query_unref(query);\n+\t\t\tstd::tie(video_pool, ret) =\n+\t\t\t\tgst_libcamera_create_video_pool(self, srcpad,\n+\t\t\t\t\t\t\t\tcaps, &info);\n+\t\t\tif (ret)\n+\t\t\t\treturn false;\n \t\t}\n\n \t\tGstLibcameraPool *pool = gst_libcamera_pool_new(self->allocator,\n",
    "prefixes": [
        "v2",
        "2/7"
    ]
}