{"id":13208,"url":"https://patchwork.libcamera.org/api/1.1/patches/13208/?format=json","web_url":"https://patchwork.libcamera.org/patch/13208/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20210805134530.825065-2-hiroh@chromium.org>","date":"2021-08-05T13:45:28","name":"[libcamera-devel,1/3] android: camera_stream: Create post porcessor in configure()","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ba5a229ff3bdc253110fdce319966d37bef3abdc","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13208/mbox/","series":[{"id":2307,"url":"https://patchwork.libcamera.org/api/1.1/series/2307/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2307","date":"2021-08-05T13:45:27","name":"android: Request one stream for identica stream requests","version":1,"mbox":"https://patchwork.libcamera.org/series/2307/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13208/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13208/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 BE699C3235\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  5 Aug 2021 13:45:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 682206880D;\n\tThu,  5 Aug 2021 15:45:42 +0200 (CEST)","from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com\n\t[IPv6:2607:f8b0:4864:20::1032])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1997E68825\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  5 Aug 2021 15:45:41 +0200 (CEST)","by mail-pj1-x1032.google.com with SMTP id mt6so8902031pjb.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 05 Aug 2021 06:45:40 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:490b:61c8:a52a:e6eb])\n\tby smtp.gmail.com with ESMTPSA id\n\tb8sm6029381pjo.51.2021.08.05.06.45.37\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 05 Aug 2021 06:45:38 -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=\"CExvTRSE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=FZ+qHQMj/SH7aTuzXMvDa5zWAyyLr8lbPyx3XK2oqUo=;\n\tb=CExvTRSENCqHLg0fH24ZiYL5BwfJGeClSoXLTMC+6yCqClVt0j16FtcrKfkJKCutxC\n\tJgAu+ZqLCKycXv3kvPwh7X+sG+aou6JpgmarC5Nl5S2ZR6iGjk0hnuCRfCsshqn+C9q+\n\tS/UyxZ7vK0zzXwq9Zd//lYZFrP2UVmkDGm19A=","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:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=FZ+qHQMj/SH7aTuzXMvDa5zWAyyLr8lbPyx3XK2oqUo=;\n\tb=FktkaJvmM1h1QcHU6njuGC/bcBJSdtGASYft/GR6zC88hjQ2Fv7t4BiKxJ1Y5wm1bw\n\tymt9jxOVfpQW3gfAx0HziyVZ9BOdnx3cc7aTJfNdg6btMpEXHte/TWB7tfdCuMt9o/yy\n\tzyYJIvWxgauyHNCMBe+68vTS16YWcqfo3jM3wndMhp/RTzN3bdU4U4CvGsbmgOrb62lA\n\tv+cL+VnvuEH0G/XTdQKKoJqau6kdHaVygFNQTK2+HfOyqAa5qAgZHVc9Tk7DfD1W+8Dc\n\tDCxFUx5fVOLdD8wfVZ1A8hqA9wnliT7BGjSB/Gt09fM7rkNOBpKyjYNVhthZT5lmmCh8\n\t9oxQ==","X-Gm-Message-State":"AOAM532nQZ84ryN9Q4HMJ4l2c4einhB+0eDuvbyM9Q5Sv0jofhzpn2Z9\n\tpMYg1XJNUaV+j1FxyC0fSaSNwZ3TFa4WOw==","X-Google-Smtp-Source":"ABdhPJyiQl7aE1RfqO8lzMdNkPQuzYjov06AWkjTvb/iro5LZtyyN0n/hccD3tUY+KGHaPxgblW6BQ==","X-Received":"by 2002:a17:902:e890:b029:12c:d39d:20bb with SMTP id\n\tw16-20020a170902e890b029012cd39d20bbmr4320124plg.83.1628171139046; \n\tThu, 05 Aug 2021 06:45:39 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  5 Aug 2021 22:45:28 +0900","Message-Id":"<20210805134530.825065-2-hiroh@chromium.org>","X-Mailer":"git-send-email 2.32.0.554.ge1b32706d8-goog","In-Reply-To":"<20210805134530.825065-1-hiroh@chromium.org>","References":"<20210805134530.825065-1-hiroh@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/3] android: camera_stream: Create post\n\tporcessor in configure()","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":"CameraStream creates PostProcessor and FrameBufferAllocator in\nthe constructor. CameraStream assumes that a used post processor\nis JPEG post processor. Since we need to support various post\nprocessors, we would rather move the creation to configure() so\nas to return an error code if no proper post processor is found.\nThis also moves FrameBufferAllocator and Mutex creation for\nconsistency.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/android/camera_device.h   |  2 ++\n src/android/camera_stream.cpp | 35 ++++++++++++++++++-----------------\n 2 files changed, 20 insertions(+), 17 deletions(-)","diff":"diff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 089a6204..cbc71be4 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -63,6 +63,8 @@ public:\n \tint processCaptureRequest(camera3_capture_request_t *request);\n \tvoid requestComplete(libcamera::Request *request);\n \n+\tlibcamera::PixelFormat toPixelFormat(int format) const;\n+\n protected:\n \tstd::string logPrefix() const override;\n \ndiff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex bf4a7b41..86263403 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -45,20 +45,6 @@ CameraStream::CameraStream(CameraDevice *const cameraDevice,\n \t: cameraDevice_(cameraDevice), config_(config), type_(type),\n \t  camera3Stream_(camera3Stream), index_(index)\n {\n-\tif (type_ == Type::Internal || type_ == Type::Mapped) {\n-\t\t/*\n-\t\t * \\todo There might be multiple post-processors. The logic\n-\t\t * which should be instantiated here, is deferred for the\n-\t\t * future. For now, we only have PostProcessorJpeg and that\n-\t\t * is what we instantiate here.\n-\t\t */\n-\t\tpostProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n-\t}\n-\n-\tif (type == Type::Internal) {\n-\t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n-\t\tmutex_ = std::make_unique<std::mutex>();\n-\t}\n }\n \n const StreamConfiguration &CameraStream::configuration() const\n@@ -73,15 +59,30 @@ Stream *CameraStream::stream() const\n \n int CameraStream::configure()\n {\n-\tif (postProcessor_) {\n+\tif (type_ == Type::Internal || type_ == Type::Mapped) {\n+\t\tconst PixelFormat outFormat =\n+\t\t\tcameraDevice_->toPixelFormat(camera3Stream_->format);\n \t\tStreamConfiguration output = configuration();\n-\t\toutput.pixelFormat = formats::MJPEG;\n+\t\toutput.pixelFormat = outFormat;\n+\t\tswitch (outFormat) {\n+\t\tcase formats::MJPEG:\n+\t\t\tpostProcessor_ = std::make_unique<PostProcessorJpeg>(cameraDevice_);\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tLOG(HAL, Error) << \"Unsupported format: \" << outFormat;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n \t\tint ret = postProcessor_->configure(configuration(), output);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\n \n-\tif (allocator_) {\n+\tif (type_ == Type::Internal) {\n+\t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n+\t\tmutex_ = std::make_unique<std::mutex>();\n+\n \t\tint ret = allocator_->allocate(stream());\n \t\tif (ret < 0)\n \t\t\treturn ret;\n","prefixes":["libcamera-devel","1/3"]}