Show a patch.

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

{
    "id": 12595,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/12595/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12595/",
    "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": "<20210615080028.2270177-1-hiroh@chromium.org>",
    "date": "2021-06-15T08:00:28",
    "name": "[libcamera-devel,v2] android: camera_device: Check if a request is configured on processCaptureRequest()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "af8b366c03a8e08c70d9e93bf59dd9e5d80b0a60",
    "submitter": {
        "id": 63,
        "url": "https://patchwork.libcamera.org/api/1.1/people/63/?format=api",
        "name": "Hirokazu Honda",
        "email": "hiroh@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/12595/mbox/",
    "series": [
        {
            "id": 2134,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2134/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2134",
            "date": "2021-06-15T08:00:28",
            "name": "[libcamera-devel,v2] android: camera_device: Check if a request is configured on processCaptureRequest()",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2134/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12595/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12595/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 63D8CC3218\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 15 Jun 2021 08:00:48 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CB47468943;\n\tTue, 15 Jun 2021 10:00:47 +0200 (CEST)",
            "from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com\n\t[IPv6:2607:f8b0:4864:20::1031])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 35EA360299\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Jun 2021 10:00:46 +0200 (CEST)",
            "by mail-pj1-x1031.google.com with SMTP id\n\tk22-20020a17090aef16b0290163512accedso1387317pjz.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Jun 2021 01:00:46 -0700 (PDT)",
            "from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:3a3f:22c6:a48a:9392])\n\tby smtp.gmail.com with ESMTPSA id\n\tk18sm1823296pff.63.2021.06.15.01.00.41\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 15 Jun 2021 01:00:43 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"hytvBuuY\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; h=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=B38Iqh22cRNogGkfOzk/XrL6JtFZ+jfTy/WOVaP5r8M=;\n\tb=hytvBuuYBMySRDmgTvj+rMTL4NlZeQV48yaFZbK8WjCOWk1+NWWExJmsBcHixDgru1\n\tCEb7nIhuGwW/gcQOd1dGbseOpbOtmwwUyacergamY5+fxtYdQRJCXnktB5PrIXR8qQCy\n\tgBZtNo8DAkmHeIi0m1w07H0NaRRE5c6d/Kii0=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=B38Iqh22cRNogGkfOzk/XrL6JtFZ+jfTy/WOVaP5r8M=;\n\tb=NPnGPDkibTRI4m6Ib9I4vRWSHjxj5U0WgJN0riPWYfIXARWVCaf6/NYrYbah1OVLJc\n\ty4osIPknlsSYuIwaf/5ioNd1v8LdMezBnQsLdPwAEsn09MK1tzHmX89as9i9ieWMHXoe\n\tmrBl2hWaPfs03M3yITtouq61f8l6Oe881eu1G+TVR4Hhntwtnv0DVJJXLM/3DPh4UtLW\n\t1aelotx01y3pL+VW2OEJXrJE+raNbmsznAblV8AYfnFTQ4K02t3GDKuy8PsGZjd9VqRw\n\tilzznrDqJOsECb8BapuMa0qQMc5VbzsaJWrQv3AWoDdiMETP0i1+5VRIl2gXUf4go7iG\n\tPHsA==",
        "X-Gm-Message-State": "AOAM531s9Y9ZT6PukkWfnKQncXWfaLjKOeNRDJ38JQb6HTaBZLjz58MQ\n\tjWnz+O+uI9ogS9xtShytYJnA+5ZREl5kdg==",
        "X-Google-Smtp-Source": "ABdhPJxdbENRwQD6J65dSuz8CqtDu5JjITp66hiov0VcAFCIOHFaeESXaTulbS0nVyl4S5a0HrGaCw==",
        "X-Received": "by 2002:a17:902:ceca:b029:112:b67b:fe4f with SMTP id\n\td10-20020a170902cecab0290112b67bfe4fmr1592652plg.32.1623744044040; \n\tTue, 15 Jun 2021 01:00:44 -0700 (PDT)",
        "From": "Hirokazu Honda <hiroh@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 15 Jun 2021 17:00:28 +0900",
        "Message-Id": "<20210615080028.2270177-1-hiroh@chromium.org>",
        "X-Mailer": "git-send-email 2.32.0.272.g935e593368-goog",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2] android: camera_device: Check if a\n\trequest is configured on processCaptureRequest()",
        "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": "Add a check on processCaptureRequest() if a given capture\nrequest contains a camera stream that has been configured.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/android/camera_device.cpp | 108 +++++++++++++++++++++-------------\n src/android/camera_device.h   |   1 +\n 2 files changed, 67 insertions(+), 42 deletions(-)",
    "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex f3fd3869..a117a904 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -10,6 +10,7 @@\n #include \"camera_ops.h\"\n #include \"post_processor.h\"\n \n+#include <algorithm>\n #include <array>\n #include <cmath>\n #include <fstream>\n@@ -260,48 +261,6 @@ void sortCamera3StreamConfigs(std::vector<Camera3StreamConfig> &unsortedConfigs,\n \tunsortedConfigs = sortedConfigs;\n }\n \n-bool isValidRequest(camera3_capture_request_t *camera3Request)\n-{\n-\tif (!camera3Request) {\n-\t\tLOG(HAL, Error) << \"No capture request provided\";\n-\t\treturn false;\n-\t}\n-\n-\tif (!camera3Request->num_output_buffers ||\n-\t    !camera3Request->output_buffers) {\n-\t\tLOG(HAL, Error) << \"No output buffers provided\";\n-\t\treturn false;\n-\t}\n-\n-\tfor (uint32_t i = 0; i < camera3Request->num_output_buffers; i++) {\n-\t\tconst camera3_stream_buffer_t &outputBuffer =\n-\t\t\tcamera3Request->output_buffers[i];\n-\t\tif (!outputBuffer.buffer || !(*outputBuffer.buffer)) {\n-\t\t\tLOG(HAL, Error) << \"Invalid native handle\";\n-\t\t\treturn false;\n-\t\t}\n-\n-\t\tconst native_handle_t *handle = *outputBuffer.buffer;\n-\t\tconstexpr int kNativeHandleMaxFds = 1024;\n-\t\tif (handle->numFds < 0 || handle->numFds > kNativeHandleMaxFds) {\n-\t\t\tLOG(HAL, Error)\n-\t\t\t\t<< \"Invalid number of fds (\" << handle->numFds\n-\t\t\t\t<< \") in buffer \" << i;\n-\t\t\treturn false;\n-\t\t}\n-\n-\t\tconstexpr int kNativeHandleMaxInts = 1024;\n-\t\tif (handle->numInts < 0 || handle->numInts > kNativeHandleMaxInts) {\n-\t\t\tLOG(HAL, Error)\n-\t\t\t\t<< \"Invalid number of ints (\" << handle->numInts\n-\t\t\t\t<< \") in buffer \" << i;\n-\t\t\treturn false;\n-\t\t}\n-\t}\n-\n-\treturn true;\n-}\n-\n const char *rotationToString(int rotation)\n {\n \tswitch (rotation) {\n@@ -1979,6 +1938,71 @@ void CameraDevice::abortRequest(camera3_capture_request_t *request)\n \tcallbacks_->process_capture_result(callbacks_, &result);\n }\n \n+bool CameraDevice::isValidRequest(camera3_capture_request_t *camera3Request) const\n+{\n+\tif (!camera3Request) {\n+\t\tLOG(HAL, Error) << \"No capture request provided\";\n+\t\treturn false;\n+\t}\n+\n+\tif (!camera3Request->num_output_buffers ||\n+\t    !camera3Request->output_buffers) {\n+\t\tLOG(HAL, Error) << \"No output buffers provided\";\n+\t\treturn false;\n+\t}\n+\n+\t/* configureStreams() has not been called or has failed. */\n+\tif (streams_.empty() || !config_) {\n+\t\tLOG(HAL, Error) << \"No stream is configured\";\n+\t\treturn false;\n+\t}\n+\n+\tfor (uint32_t i = 0; i < camera3Request->num_output_buffers; i++) {\n+\t\tconst camera3_stream_buffer_t &outputBuffer =\n+\t\t\tcamera3Request->output_buffers[i];\n+\t\tif (!outputBuffer.buffer || !(*outputBuffer.buffer)) {\n+\t\t\tLOG(HAL, Error) << \"Invalid native handle\";\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tconst native_handle_t *handle = *outputBuffer.buffer;\n+\t\tconstexpr int kNativeHandleMaxFds = 1024;\n+\t\tif (handle->numFds < 0 || handle->numFds > kNativeHandleMaxFds) {\n+\t\t\tLOG(HAL, Error)\n+\t\t\t\t<< \"Invalid number of fds (\" << handle->numFds\n+\t\t\t\t<< \") in buffer \" << i;\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tconstexpr int kNativeHandleMaxInts = 1024;\n+\t\tif (handle->numInts < 0 || handle->numInts > kNativeHandleMaxInts) {\n+\t\t\tLOG(HAL, Error)\n+\t\t\t\t<< \"Invalid number of ints (\" << handle->numInts\n+\t\t\t\t<< \") in buffer \" << i;\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tconst camera3_stream *camera3Stream = outputBuffer.stream;\n+\t\tif (!camera3Stream)\n+\t\t\treturn false;\n+\n+\t\tconst CameraStream *cameraStream =\n+\t\t\tstatic_cast<CameraStream *>(camera3Stream->priv);\n+\n+\t\tauto found = std::find_if(streams_.begin(), streams_.end(),\n+\t\t\t\t\t  [cameraStream](const CameraStream &stream) {\n+\t\t\t\t\t\t  return &stream == cameraStream;\n+\t\t\t\t\t  });\n+\t\tif (found == streams_.end()) {\n+\t\t\tLOG(HAL, Error)\n+\t\t\t\t<< \"No corresponding configured stream found\";\n+\t\t\treturn false;\n+\t\t}\n+\t}\n+\n+\treturn true;\n+}\n+\n int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request)\n {\n \tif (!isValidRequest(camera3Request))\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 4aadb27c..4d9c904d 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -109,6 +109,7 @@ private:\n \n \tlibcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);\n \tvoid abortRequest(camera3_capture_request_t *request);\n+\tbool isValidRequest(camera3_capture_request_t *request) const;\n \tvoid notifyShutter(uint32_t frameNumber, uint64_t timestamp);\n \tvoid notifyError(uint32_t frameNumber, camera3_stream_t *stream,\n \t\t\t camera3_error_msg_code code);\n",
    "prefixes": [
        "libcamera-devel",
        "v2"
    ]
}