[{"id":16588,"web_url":"https://patchwork.libcamera.org/comment/16588/","msgid":"<CAO5uPHOzRE_1PxtWqm8N6gnpQjHVe5EBRoY-j-nq8oviym867g@mail.gmail.com>","date":"2021-04-26T11:01:54","subject":"Re: [libcamera-devel] [PATCH v2] android: CameraDevice: factorize\n\treporting a capture result","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"With this implementation, stop() can be as follows.\n\n$ git diff\ndiff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 70174a2b..c5091e4f 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -773,19 +773,8 @@ void CameraDevice::stop()\n                for (auto &[cookie, descriptor] : descriptors_) {\n                        LOG(HAL, Debug) << \"request is canceled: \" << cookie;\n\n-                       camera3_capture_result_t captureResult = {};\n-                       captureResult.frame_number = descriptor.frameNumber_;\n-                       captureResult.num_output_buffers =\ndescriptor.buffers_.size();\n-                       for (camera3_stream_buffer_t &buffer :\ndescriptor.buffers_) {\n-                               buffer.acquire_fence = -1;\n-                               buffer.release_fence = -1;\n-                               buffer.status = CAMERA3_BUFFER_STATUS_ERROR;\n-                       }\n-                       captureResult.output_buffers =\ndescriptor.buffers_.data();\n-\n-                       notifyError(descriptor.frameNumber_,\n-                                   descriptor.buffers_[0].stream);\n-                       callbacks_->process_capture_result(callbacks_,\n&captureResult);\n+                       reportDescriptor(descriptor,\n+                                        CAMERA3_BUFFER_STATUS_ERROR);\n                }\n\n                descriptors_.clear();\n\nOn Mon, Apr 26, 2021 at 7:57 PM Hirokazu Honda <hiroh@chromium.org> wrote:\n>\n> This factorizes a code of reporting a capture result including\n> notifying either shutter or error. It will be useful to report\n> capture results in other places than\n> CameraDevice::reqeustComplete().\n>\n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  src/android/camera_device.cpp | 22 +++++++++++++++-------\n>  src/android/camera_device.h   |  4 ++++\n>  2 files changed, 19 insertions(+), 7 deletions(-)\n>\n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index fb89195e..70174a2b 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -2132,7 +2132,20 @@ void CameraDevice::requestComplete(Request *request)\n>                         cameraStream->putBuffer(src);\n>         }\n>\n> -       /* Prepare to call back the Android camera stack. */\n> +       reportDescriptor(descriptor, status, timestamp,\n> +                        resultMetadata ? resultMetadata->get() : nullptr);\n> +}\n> +\n> +std::string CameraDevice::logPrefix() const\n> +{\n> +       return \"'\" + camera_->id() + \"'\";\n> +}\n> +\n> +void CameraDevice::reportDescriptor(Camera3RequestDescriptor &descriptor,\n> +                                   camera3_buffer_status status,\n> +                                   uint64_t timestamp,\n> +                                   camera_metadata_t *metadata)\n> +{\n>         camera3_capture_result_t captureResult = {};\n>         captureResult.frame_number = descriptor.frameNumber_;\n>         captureResult.num_output_buffers = descriptor.buffers_.size();\n> @@ -2147,7 +2160,7 @@ void CameraDevice::requestComplete(Request *request)\n>                 notifyShutter(descriptor.frameNumber_, timestamp);\n>\n>                 captureResult.partial_result = 1;\n> -               captureResult.result = resultMetadata->get();\n> +               captureResult.result = metadata;\n>         }\n>\n>         if (status == CAMERA3_BUFFER_STATUS_ERROR || !captureResult.result) {\n> @@ -2164,11 +2177,6 @@ void CameraDevice::requestComplete(Request *request)\n>         callbacks_->process_capture_result(callbacks_, &captureResult);\n>  }\n>\n> -std::string CameraDevice::logPrefix() const\n> -{\n> -       return \"'\" + camera_->id() + \"'\";\n> -}\n> -\n>  void CameraDevice::notifyShutter(uint32_t frameNumber, uint64_t timestamp)\n>  {\n>         camera3_notify_msg_t notify = {};\n> diff --git a/src/android/camera_device.h b/src/android/camera_device.h\n> index fa652c3c..a42b8dc0 100644\n> --- a/src/android/camera_device.h\n> +++ b/src/android/camera_device.h\n> @@ -101,6 +101,10 @@ private:\n>\n>         std::tuple<uint32_t, uint32_t> calculateStaticMetadataSize();\n>         libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);\n> +       void reportDescriptor(Camera3RequestDescriptor &descriptor,\n> +                             camera3_buffer_status status,\n> +                             uint64_t timestamp = 0,\n> +                             camera_metadata_t *metadata = nullptr);\n>         void notifyShutter(uint32_t frameNumber, uint64_t timestamp);\n>         void notifyError(uint32_t frameNumber, camera3_stream_t *stream);\n>         std::unique_ptr<CameraMetadata> requestTemplatePreview();\n> --\n> 2.31.1.498.g6c1eba8ee3d-goog\n>","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 56329BDC9C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Apr 2021 11:02:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 167D468880;\n\tMon, 26 Apr 2021 13:02:07 +0200 (CEST)","from mail-ej1-x629.google.com (mail-ej1-x629.google.com\n\t[IPv6:2a00:1450:4864:20::629])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A64C0605BE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Apr 2021 13:02:05 +0200 (CEST)","by mail-ej1-x629.google.com with SMTP id u21so83809589ejo.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Apr 2021 04:02:05 -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=\"jOG9rzor\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to;\n\tbh=jPi/zF/Eqwa+4yMA5nBKuuEL4YzGemjvfcqwuT44MDo=;\n\tb=jOG9rzoreHLpkbQ6EOORpK4+lE04igrXLL7nna0c36l7rv9Z127a9TaxRjcgfRNhJK\n\tg+rvYV1WEJ4jxHOfalTUwbz05+nvdW5ebYe3TOQZL4seDSp8t0k19ntIBIAbEa8JUBhI\n\tl4fLljz16dAzz9y3VmQFLWWklXJaT1ZoQpASc=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to;\n\tbh=jPi/zF/Eqwa+4yMA5nBKuuEL4YzGemjvfcqwuT44MDo=;\n\tb=macAS1ZWXcVFUiHk8VXUtlC8xUdJwqJsrFOw0JUBqfBsEhrfNtChRQvaOhpX0OdUJP\n\tb/0yyBW/vdV/UOzfrvUkkQxmTBqCyDMuu4kiTuYwJbLsoUBhf/EqCcsPx8WOhBqJH2yR\n\tDEcaiHdGJJyDVkb9h7snlakf0o5rNTd76rld695triZRdi2nycg2Um9Wp/00wWL7uqwo\n\tyqp9ZxsqRVCXLk5U3ctNmYlU1Fm6gnssJ1O3M2ga9If7NO+wqBR85mgbTxhR78frLpT8\n\tg/WL2g2Wrxh86MvAk0cw+NTDSEjARx28vehYEZLdUMBai9SxShXJzxvZrQq/4sYjdz6e\n\tPP3g==","X-Gm-Message-State":"AOAM531Z3+wEFFOYeh6SA1dKFmquW6Us/Vhsr+9r/6wDnWlAirT6p07Y\n\titNtwkIKhp7IOFixdblPzNtMwwiF1CxS2E0qdMfnwXISoxUMUA==","X-Google-Smtp-Source":"ABdhPJz0hxOD2FbhtYIpCi+00xsV0s+y6BZAuCpnLObqvUfpp3hPXdFLpmpLtBFNssQGTW80iKdpzBUJ2L13f5KcbTc=","X-Received":"by 2002:a17:906:fcc4:: with SMTP id\n\tqx4mr17428717ejb.42.1619434924997; \n\tMon, 26 Apr 2021 04:02:04 -0700 (PDT)","MIME-Version":"1.0","References":"<20210426105753.3498691-1-hiroh@chromium.org>","In-Reply-To":"<20210426105753.3498691-1-hiroh@chromium.org>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Mon, 26 Apr 2021 20:01:54 +0900","Message-ID":"<CAO5uPHOzRE_1PxtWqm8N6gnpQjHVe5EBRoY-j-nq8oviym867g@mail.gmail.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Subject":"Re: [libcamera-devel] [PATCH v2] android: CameraDevice: factorize\n\treporting a capture result","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]