{"id":12579,"url":"https://patchwork.libcamera.org/api/patches/12579/?format=json","web_url":"https://patchwork.libcamera.org/patch/12579/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210614060303.2405391-1-hiroh@chromium.org>","date":"2021-06-14T06:03:03","name":"[libcamera-devel] android: camera_device: Check if a request is configured on processCaptureRequest()","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"32df2abc009f4e4b645cc2f9906297a3cf9b276f","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12579/mbox/","series":[{"id":2127,"url":"https://patchwork.libcamera.org/api/series/2127/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2127","date":"2021-06-14T06:03:03","name":"[libcamera-devel] android: camera_device: Check if a request is configured on processCaptureRequest()","version":1,"mbox":"https://patchwork.libcamera.org/series/2127/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12579/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12579/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 25747BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 14 Jun 2021 06:03:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 955BB60297;\n\tMon, 14 Jun 2021 08:03:19 +0200 (CEST)","from mail-pf1-x431.google.com (mail-pf1-x431.google.com\n\t[IPv6:2607:f8b0:4864:20::431])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9389760297\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Jun 2021 08:03:16 +0200 (CEST)","by mail-pf1-x431.google.com with SMTP id x73so9735022pfc.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 13 Jun 2021 23:03:16 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:dd3f:f6f0:e98e:863b])\n\tby smtp.gmail.com with ESMTPSA id\n\tz8sm12301577pgi.94.2021.06.13.23.03.12\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 13 Jun 2021 23:03:13 -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=\"V2Lmmae1\"; 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=6ESIk4OGCxodVIKa0LlH9gHL2Jgk4Za1DflAec8BqV8=;\n\tb=V2Lmmae16XGtANLwyLWuR7TZRaI/hBQTcGHvieafNzYUTSdcW2RnKMZWjK1D06E2PY\n\t4Of6ilemI8GF+75L0t1uFifQ2t+kCHomBOSvcP7A5KdZZ0ba7fTWWtzjJcmRCmxfIT/t\n\tJ1eJPhOsw3nZD5q7Bb9nAClaZQnkRTDIkfG58=","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=6ESIk4OGCxodVIKa0LlH9gHL2Jgk4Za1DflAec8BqV8=;\n\tb=krlnXXfwiHjD2TuxF0rIL0sGTMUgJvj13zAOteHwI9mfElN2C6uWcwb9EdgMNxPBIr\n\tbdju0Fp1gFX1QtZ14fIOOysIndUl+z+AWYL6H/WI8Hx2f30yMVtntO5SIV8Tp/xi2U3I\n\tfOlKrih9BZQ4D37Xq24eZiLZlUQ9ywZKpd6vhV+vpS3DkOy9XtTB7d7g1I0FvrNR2uLf\n\txFBsqsgPLnt/wbToTojSEChN4eKrbuzxLi/Xso/3c2cEnUv9ZcM8QkXDUqGOuuowoMx+\n\tp+SD5Jl//+FDoPCcXLR9y3QDie9phD5fSwOSwOIy6FChB+yda6xcwOJJkpMuTPkUcZfA\n\tF9Cw==","X-Gm-Message-State":"AOAM532ZrpTc63xCycvXZuxHg1OEHVFH/cj9bYvEG2F4V7oTUxuDABZq\n\tO4QSGMsqFWmTpIR6RfcKTFDK2RME48CuGA==","X-Google-Smtp-Source":"ABdhPJwkcb5tDjAw3DJvr8LUkRUx7KpesXeU8ZpRYGq/n3XKoLWWfCKWMnV/JvrHXv5sNKW+fxIvZA==","X-Received":"by 2002:aa7:96e3:0:b029:2ec:e8a1:3d66 with SMTP id\n\ti3-20020aa796e30000b02902ece8a13d66mr20141661pfq.79.1623650594413; \n\tSun, 13 Jun 2021 23:03:14 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 14 Jun 2021 15:03:03 +0900","Message-Id":"<20210614060303.2405391-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] 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":"Adds 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>\n---\n src/android/camera_device.cpp | 111 +++++++++++++++++++++-------------\n src/android/camera_device.h   |   1 +\n 2 files changed, 70 insertions(+), 42 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 3adb657b..5b182257 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -260,48 +260,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@@ -1934,6 +1892,75 @@ 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() is not called or fails.\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\tbool found = false;\n+\t\tfor (const CameraStream &stream : streams_) {\n+\t\t\tif (&stream == cameraStream) {\n+\t\t\t\tfound = true;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (!found) {\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"]}