{"id":22166,"url":"https://patchwork.libcamera.org/api/patches/22166/?format=json","web_url":"https://patchwork.libcamera.org/patch/22166/","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":"<20241204164137.3938891-5-chenghaoyang@chromium.org>","date":"2024-12-04T16:36:29","name":"[v3,4/7] android: Add CameraDevice::sendCaptureResult()","commit_ref":null,"pull_url":null,"state":"superseded","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/22166/mbox/","series":[{"id":4847,"url":"https://patchwork.libcamera.org/api/series/4847/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4847","date":"2024-12-04T16:36:25","name":"Refactor Android HAL before supporting partial result","version":3,"mbox":"https://patchwork.libcamera.org/series/4847/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22166/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22166/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 72964BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  4 Dec 2024 16:41:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 01951660EE;\n\tWed,  4 Dec 2024 17:41:56 +0100 (CET)","from mail-pl1-x635.google.com (mail-pl1-x635.google.com\n\t[IPv6:2607:f8b0:4864:20::635])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 350E2660C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Dec 2024 17:41:51 +0100 (CET)","by mail-pl1-x635.google.com with SMTP id\n\td9443c01a7336-21572ca3cccso38664565ad.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 04 Dec 2024 08:41:51 -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\td2e1a72fcca58-725417725e9sm12551779b3a.80.2024.12.04.08.41.46\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 04 Dec 2024 08:41:47 -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=\"Hx02CMGh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1733330508; x=1733935308;\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=SW0ReRfQT80HjLN0627g1Oa3EjdkMjs9/avml1BZiic=;\n\tb=Hx02CMGhIvUuKLDjp10qxPdPfEe3CwgWKlLZABIcK9n9UXW49Nek2kIi6+fYZSTX6K\n\tgyx90hqy97UQ/3RFJMe/6jCuduN2ownzLO2cHZM0HnZeKNbj1mfnZ5k+N2xKdOktr6Lu\n\tttho2z8vsemG3OSC1GwjeAezJv3owMeMVfpMA=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1733330508; x=1733935308;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=SW0ReRfQT80HjLN0627g1Oa3EjdkMjs9/avml1BZiic=;\n\tb=BvnACHeqyR4Mfg5Rbi+8lQwNJ2U2BZItfWeynfOH+KFd/Gtg5r26sQ6aBJOmdQH7sR\n\tego8+oAckq0mogRQ8HHvH36Sa2nMDXTngkBROgig0WUjEAB2bLrYKG+zBQKm8LAaKrtP\n\tiEDqmfnD+UY87HK7QGSpy3l64oRzEs0far6//HVUokhfuxhFer3g9krJDrtiCGSATENP\n\t0LMOWhUCaVHgcP0zK9mL5YktZHeZ3SBVbcuFw3agxQ/CR8JWH2AdYLcEh+bTs8Y7wi+5\n\thKgNY8C/jf8RSrwttkb6ayel3lvEUaJXSHhat1IZAlswUlzChbUnX7w1LWXtQlSaisfc\n\tAwtQ==","X-Gm-Message-State":"AOJu0YzTyRR+sqDfsIwMmE+rv9cEMDtAcvAqcZoCGv9kzHKyLfZs3h0y\n\tJluEgtSFYi5XrM1Vt5KtQ807j28XCs4EXMjKjy4ZcsA5ZT08jF6iGOiwDjp4oc7i4T/4PXFv7t8\n\t=","X-Gm-Gg":"ASbGncuL2Uox8Lno0NNviRbzKzGna6hdTzk92Arf417kqF3Do+pfTf97mTxno3rFzj/\n\t4FgeCQDWvHjwZrp5Bs9u7NMPcGIxEbFjFV00/OYBlWOnGNfBcVYoYyqil9E59HkpfHptLGuowfZ\n\tWGTTN3ceoHuSI9n2jMT5Yrj+80ytsS4csWY6gBnmOdTIwkhAe3d5brWsM01M9ukfSwrzM696axE\n\tJb9nePikeDfceZwA8K47ZLEx2D8U9ECj0oRrqzzokc3/fEtbSGjPPIPsKbWABOqlH632Hxm0a+q\n\t0GAFF45Z9BHkI9IgLlanevO1R3yS4UsQQ23IieE8KoGCLURAvOlbWIw9","X-Google-Smtp-Source":"AGHT+IGtYS/y7Qc8dbU0w8S14phcpaspCB7oQFpIJJhQ1iSeKtXIAW+JGdNReK/9N8vGShN+d1UKQg==","X-Received":"by 2002:a17:903:1790:b0:215:711f:4979 with SMTP id\n\td9443c01a7336-215bd24b939mr107924905ad.35.1733330508309; \n\tWed, 04 Dec 2024 08:41:48 -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 v3 4/7] android: Add CameraDevice::sendCaptureResult()","Date":"Wed,  4 Dec 2024 16:36:29 +0000","Message-ID":"<20241204164137.3938891-5-chenghaoyang@chromium.org>","X-Mailer":"git-send-email 2.47.0.338.g60cca15819-goog","In-Reply-To":"<20241204164137.3938891-1-chenghaoyang@chromium.org>","References":"<20241204164137.3938891-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 f2dd8d4fd..497d363d6 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1324,42 +1324,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":["v3","4/7"]}