{"id":22272,"url":"https://patchwork.libcamera.org/api/patches/22272/?format=json","web_url":"https://patchwork.libcamera.org/patch/22272/","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":"<20241210142557.2886315-5-chenghaoyang@chromium.org>","date":"2024-12-10T14:23:57","name":"[v4,4/7] android: Add CameraDevice::sendCaptureResult()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"1b84b5a6f65287a75f651b26acd0a24c857f0564","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/people/117/?format=json","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22272/mbox/","series":[{"id":4870,"url":"https://patchwork.libcamera.org/api/series/4870/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4870","date":"2024-12-10T14:23:53","name":"Refactor Android HAL before supporting partial result","version":4,"mbox":"https://patchwork.libcamera.org/series/4870/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22272/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22272/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 BBF03C32DC\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 10 Dec 2024 14:26:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3C59B67E94;\n\tTue, 10 Dec 2024 15:26:12 +0100 (CET)","from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com\n\t[IPv6:2607:f8b0:4864:20::102a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B47A967E92\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Dec 2024 15:26:09 +0100 (CET)","by mail-pj1-x102a.google.com with SMTP id\n\t98e67ed59e1d1-2ef6af22ea8so3851186a91.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 Dec 2024 06:26:09 -0800 (PST)","from chenghaoyang-low.c.googlers.com.com\n\t(112.212.229.35.bc.googleusercontent.com. [35.229.212.112])\n\tby smtp.gmail.com with ESMTPSA id\n\t98e67ed59e1d1-2ef26ff97f2sm11812053a91.11.2024.12.10.06.26.06\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 10 Dec 2024 06:26:07 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"dhXFYs1L\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1733840768; x=1734445568;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=Q96BeC7n8E+Cipc4Avk4B1MuW6eoeZ2GDO3TPgfwR30=;\n\tb=dhXFYs1LrB0+HBSg2q4L9eooFL183G9znQoZ+gGhPuZa2A6m9rYjlPLYwIsLTZye7s\n\tdSoKB3EXHxYYS/5m/jTu9eg2lYg/xdkbOu8GTZLFhKMUkSMNZHkQZkgEXDzLK7Ih9k6N\n\t09nX8tJIT+FM0J3Ey8Uerdh8rpab6ngmdtiBY=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1733840768; x=1734445568;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-g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WPOm+L/EDQ==","X-Received":"by 2002:a17:90b:4b10:b0:2ee:535f:ac27 with SMTP id\n\t98e67ed59e1d1-2efcf2c572dmr7671921a91.33.1733840767895; \n\tTue, 10 Dec 2024 06:26:07 -0800 (PST)","From":"Harvey Yang <chenghaoyang@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Cc":"Harvey Yang <chenghaoyang@chromium.org>,\n\tHan-Lin Chen <hanlinchen@chromium.org>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>","Subject":"[PATCH v4 4/7] android: Add CameraDevice::sendCaptureResult()","Date":"Tue, 10 Dec 2024 14:23:57 +0000","Message-ID":"<20241210142557.2886315-5-chenghaoyang@chromium.org>","X-Mailer":"git-send-email 2.47.0.338.g60cca15819-goog","In-Reply-To":"<20241210142557.2886315-1-chenghaoyang@chromium.org>","References":"<20241210142557.2886315-1-chenghaoyang@chromium.org>","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 new function is separated from sendCaptureResults(), which allows\nother functions to send a result out of order, like aborting. It'll be\nupdated in the upcoming patch, when the usage of error result is\nseparated.\n\nThis function also allows the upcoming partial results to be sent back\nto the application without waiting for the requests.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\nCo-developed-by: Harvey Yang <chenghaoyang@chromium.org>\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/android/camera_device.cpp | 57 ++++++++++++++++++-----------------\n src/android/camera_device.h   |  1 +\n 2 files changed, 31 insertions(+), 27 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 6bc19a74a..f3f570544 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1323,42 +1323,45 @@ void CameraDevice::sendCaptureResults()\n \t\tauto descriptor = std::move(descriptors_.front());\n \t\tdescriptors_.pop();\n \n-\t\tcamera3_capture_result_t captureResult = {};\n+\t\tsendCaptureResult(descriptor.get());\n+\t}\n+}\n \n-\t\tcaptureResult.frame_number = descriptor->frameNumber_;\n+void CameraDevice::sendCaptureResult(Camera3RequestDescriptor *request) const\n+{\n+\tstd::vector<camera3_stream_buffer_t> resultBuffers;\n+\tresultBuffers.reserve(request->buffers_.size());\n \n-\t\tif (descriptor->resultMetadata_)\n-\t\t\tcaptureResult.result =\n-\t\t\t\tdescriptor->resultMetadata_->getMetadata();\n+\tfor (auto &buffer : request->buffers_) {\n+\t\tcamera3_buffer_status status = CAMERA3_BUFFER_STATUS_ERROR;\n \n-\t\tstd::vector<camera3_stream_buffer_t> resultBuffers;\n-\t\tresultBuffers.reserve(descriptor->buffers_.size());\n+\t\tif (buffer.status == StreamBuffer::Status::Success)\n+\t\t\tstatus = CAMERA3_BUFFER_STATUS_OK;\n \n-\t\tfor (auto &buffer : descriptor->buffers_) {\n-\t\t\tcamera3_buffer_status status = CAMERA3_BUFFER_STATUS_ERROR;\n+\t\t/*\n+\t\t * Pass the buffer fence back to the camera framework as\n+\t\t * a release fence. This instructs the framework to wait\n+\t\t * on the acquire fence in case we haven't done so\n+\t\t * ourselves for any reason.\n+\t\t */\n+\t\tresultBuffers.push_back({ buffer.stream->camera3Stream(),\n+\t\t\t\t\t  buffer.camera3Buffer, status,\n+\t\t\t\t\t  -1, buffer.fence.release() });\n+\t}\n \n-\t\t\tif (buffer.status == StreamBuffer::Status::Success)\n-\t\t\t\tstatus = CAMERA3_BUFFER_STATUS_OK;\n+\tcamera3_capture_result_t captureResult = {};\n \n-\t\t\t/*\n-\t\t\t * Pass the buffer fence back to the camera framework as\n-\t\t\t * a release fence. This instructs the framework to wait\n-\t\t\t * on the acquire fence in case we haven't done so\n-\t\t\t * ourselves for any reason.\n-\t\t\t */\n-\t\t\tresultBuffers.push_back({ buffer.stream->camera3Stream(),\n-\t\t\t\t\t\t  buffer.camera3Buffer, status,\n-\t\t\t\t\t\t  -1, buffer.fence.release() });\n-\t\t}\n+\tcaptureResult.frame_number = request->frameNumber_;\n+\tcaptureResult.num_output_buffers = resultBuffers.size();\n+\tcaptureResult.output_buffers = resultBuffers.data();\n \n-\t\tcaptureResult.num_output_buffers = resultBuffers.size();\n-\t\tcaptureResult.output_buffers = resultBuffers.data();\n+\tif (request->status_ == Camera3RequestDescriptor::Status::Success)\n+\t\tcaptureResult.partial_result = 1;\n \n-\t\tif (descriptor->status_ == Camera3RequestDescriptor::Status::Success)\n-\t\t\tcaptureResult.partial_result = 1;\n+\tif (request->resultMetadata_)\n+\t\tcaptureResult.result = request->resultMetadata_->getMetadata();\n \n-\t\tcallbacks_->process_capture_result(callbacks_, &captureResult);\n-\t}\n+\tcallbacks_->process_capture_result(callbacks_, &captureResult);\n }\n \n void CameraDevice::setBufferStatus(StreamBuffer &streamBuffer,\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex c92ee1aa4..699aa8f17 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -97,6 +97,7 @@ private:\n \tvoid completeDescriptor(Camera3RequestDescriptor *descriptor)\n \t\tLIBCAMERA_TSA_EXCLUDES(descriptorsMutex_);\n \tvoid sendCaptureResults() LIBCAMERA_TSA_REQUIRES(descriptorsMutex_);\n+\tvoid sendCaptureResult(Camera3RequestDescriptor *request) const;\n \tvoid setBufferStatus(StreamBuffer &buffer,\n \t\t\t     StreamBuffer::Status status);\n \tstd::unique_ptr<CameraMetadata> getResultMetadata(\n","prefixes":["v4","4/7"]}