Show a patch.

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

{
    "id": 23425,
    "url": "https://patchwork.libcamera.org/api/patches/23425/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23425/",
    "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": "<20250522125521.6465-3-laurent.pinchart@ideasonboard.com>",
    "date": "2025-05-22T12:55:19",
    "name": "[2/4] gstreamer: Factor out video pool creation",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "eab53e2722eaf5eff7c916e87bc9943ef15ac047",
    "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/23425/mbox/",
    "series": [
        {
            "id": 5190,
            "url": "https://patchwork.libcamera.org/api/series/5190/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5190",
            "date": "2025-05-22T12:55:17",
            "name": "gstreamer: Miscellaneous cleanups + one fix",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5190/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23425/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23425/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 2855EBD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 May 2025 12:55:34 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C773668D9B;\n\tThu, 22 May 2025 14:55:33 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D4C6968D92\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 May 2025 14:55:29 +0200 (CEST)",
            "from pendragon.ideasonboard.com\n\t(179.218-130-109.adsl-dyn.isp.belgacom.be [109.130.218.179])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BA39C15CD;\n\tThu, 22 May 2025 14:55:07 +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=\"nh75XIrW\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1747918507;\n\tbh=ZyOq4JeBMI4QxQF0ouaocowAotYzfiVQpomnBIltlAo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=nh75XIrWiMFGQDvbd1P/SEenEFOIw2R6l8b9xLBQo/aTpWSB+3GxPMBmmTmWvj2K3\n\tqL/yWzWvKlJsNqjWGVKo5BdSIoVijGh2EX+sf8h9/plUPDtR7gB//NnTd4NLQh6nIy\n\t05myOJH2YvR7J92vhO0gDOz4M5MrwSsyBJFSi8Ow=",
        "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 2/4] gstreamer: Factor out video pool creation",
        "Date": "Thu, 22 May 2025 14:55:19 +0200",
        "Message-ID": "<20250522125521.6465-3-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.49.0",
        "In-Reply-To": "<20250522125521.6465-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20250522125521.6465-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---\n src/gstreamer/gstlibcamerasrc.cpp | 105 +++++++++++++++++-------------\n 1 file changed, 61 insertions(+), 44 deletions(-)",
    "diff": "diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp\nindex 70bb0606c72c..71f5700d9de7 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@@ -519,6 +520,61 @@ gst_libcamera_src_open(GstLibcameraSrc *self)\n \treturn true;\n }\n \n+static std::tuple<GstBufferPool *, int>\n+gst_libcamera_create_video_pool(GstLibcameraSrc *self,\n+\t\t\t\tconst StreamConfiguration &stream_cfg,\n+\t\t\t\tGstVideoInfo *info, GstPad *srcpad,\n+\t\t\t\tGstCaps *caps)\n+{\n+\tGstQuery *query = NULL;\n+\tconst gboolean need_pool = true;\n+\tgboolean has_video_meta = false;\n+\tGstBufferPool *video_pool = NULL;\n+\n+\tgst_libcamera_extrapolate_info(info, stream_cfg.stride);\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@@ -601,50 +657,11 @@ 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, stream_cfg,\n+\t\t\t\t\t\t\t\t&info, srcpad, caps);\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": [
        "2/4"
    ]
}