{"id":9954,"url":"https://patchwork.libcamera.org/api/patches/9954/?format=json","web_url":"https://patchwork.libcamera.org/patch/9954/","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":"<20201005104649.10812-8-laurent.pinchart@ideasonboard.com>","date":"2020-10-05T10:46:41","name":"[libcamera-devel,07/15] android: camera_stream: Fetch format and size from configuration","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"160db5bf62d9360ee5c06a279b4532584889a66b","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9954/mbox/","series":[{"id":1349,"url":"https://patchwork.libcamera.org/api/series/1349/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1349","date":"2020-10-05T10:46:34","name":"CameraStream refactoring","version":1,"mbox":"https://patchwork.libcamera.org/series/1349/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9954/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9954/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 B9B65C3B5D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  5 Oct 2020 10:47:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8699263C28;\n\tMon,  5 Oct 2020 12:47:41 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 565AB63BE4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  5 Oct 2020 12:47:36 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DE6D459E;\n\tMon,  5 Oct 2020 12:47:35 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"u8cEvUwi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1601894856;\n\tbh=JYDBx5///bDfgq/WJy1yIFW5fPWTppIQIlFq5wDLLKw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=u8cEvUwitNzfIJsyjYOT+YpsOox34nzFUU/Szbq01QSyiQ+bMw+rtcXvgr4ZGgFV1\n\tq4zjaA+5bYUCwAwmqwwho23JuUtU2cwdVr/xv4Gel/5bv6ZyquwUrjVO3OhkmLK0HM\n\t1tlRWLzRn8QZA+DVbtQLJwv9EGPEDlpgCQy4Wp2k=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon,  5 Oct 2020 13:46:41 +0300","Message-Id":"<20201005104649.10812-8-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20201005104649.10812-1-laurent.pinchart@ideasonboard.com>","References":"<20201005104649.10812-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 07/15] android: camera_stream: Fetch\n\tformat and size from configuration","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>"},"content":"From: Jacopo Mondi <jacopo@jmondi.org>\n\nFetch the format and size of the libcamera::StreamConfiguration\nassociated with a CameraStream by accessing the configuration by\nindex.\n\nThis removes the need to store the libcamera stream format and sizes\nas class members and avoid duplicating information that might get out\nof sync.\n\nIt also allows to remove the StreamConfiguration from the constructor\nparameters list, as it can be identified by its index. While at it,\nre-order the constructor parameters order.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp |  8 +++-----\n src/android/camera_stream.cpp | 23 ++++++++++++++---------\n src/android/camera_stream.h   | 18 ++++++------------\n 3 files changed, 23 insertions(+), 26 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 4f8f3e5790ca..adaec54dbfdb 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1206,9 +1206,8 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\tstreamConfiguration.pixelFormat = format;\n \n \t\tconfig_->addConfiguration(streamConfiguration);\n-\t\tunsigned int index = config_->size() - 1;\n-\t\tstreams_.emplace_back(this, stream, streamConfiguration,\n-\t\t\t\t      CameraStream::Type::Direct, index);\n+\t\tstreams_.emplace_back(this, CameraStream::Type::Direct,\n+\t\t\t\t      stream, config_->size() - 1);\n \t\tstream->priv = static_cast<void *>(&streams_.back());\n \t}\n \n@@ -1262,8 +1261,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\t\tindex = config_->size() - 1;\n \t\t}\n \n-\t\tStreamConfiguration &cfg = config_->at(index);\n-\t\tstreams_.emplace_back(this, jpegStream, cfg, type, index);\n+\t\tstreams_.emplace_back(this, type, jpegStream, index);\n \t\tjpegStream->priv = static_cast<void *>(&streams_.back());\n \t}\n \ndiff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex 250f0ab0a3b4..6e7419ae31b8 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -16,18 +16,13 @@ using namespace libcamera;\n \n LOG_DECLARE_CATEGORY(HAL);\n \n-CameraStream::CameraStream(CameraDevice *cameraDev,\n-\t\t\t   camera3_stream_t *androidStream,\n-\t\t\t   const libcamera::StreamConfiguration &cfg,\n-\t\t\t   Type type, unsigned int index)\n-\t: cameraDevice_(cameraDev), androidStream_(androidStream), type_(type),\n+CameraStream::CameraStream(CameraDevice *cameraDev, Type type,\n+\t\t\t   camera3_stream_t *androidStream, unsigned int index)\n+\t: cameraDevice_(cameraDev), type_(type), androidStream_(androidStream),\n \t  index_(index), encoder_(nullptr)\n {\n \tconfig_ = cameraDevice_->cameraConfiguration();\n \n-\tformat_ = cfg.pixelFormat;\n-\tsize_ = cfg.size;\n-\n \tif (type_ == Type::Internal || type_ == Type::Mapped)\n \t\tencoder_.reset(new EncoderLibJpeg);\n }\n@@ -42,6 +37,16 @@ Stream *CameraStream::stream() const\n \treturn streamConfiguration().stream();\n }\n \n+const PixelFormat &CameraStream::format() const\n+{\n+\treturn streamConfiguration().pixelFormat;\n+}\n+\n+const Size &CameraStream::size() const\n+{\n+\treturn streamConfiguration().size;\n+}\n+\n int CameraStream::configure(const libcamera::StreamConfiguration &cfg)\n {\n \tif (encoder_)\n@@ -62,7 +67,7 @@ int CameraStream::process(libcamera::FrameBuffer *source, MappedCamera3Buffer *d\n \texif.setMake(\"libcamera\");\n \texif.setModel(\"cameraModel\");\n \texif.setOrientation(cameraDevice_->orientation());\n-\texif.setSize(size_);\n+\texif.setSize(size());\n \t/*\n \t * We set the frame's EXIF timestamp as the time of encode.\n \t * Since the precision we need for EXIF timestamp is only one\ndiff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\nindex fa295a69404f..b67b4c0ca0b3 100644\n--- a/src/android/camera_stream.h\n+++ b/src/android/camera_stream.h\n@@ -107,18 +107,16 @@ public:\n \t\tInternal,\n \t\tMapped,\n \t};\n-\tCameraStream(CameraDevice *cameraDev,\n-\t\t     camera3_stream_t *androidStream,\n-\t\t     const libcamera::StreamConfiguration &cfg,\n-\t\t     Type type, unsigned int index);\n+\tCameraStream(CameraDevice *cameraDev, Type type,\n+\t\t     camera3_stream_t *androidStream, unsigned int index);\n \n \tint outputFormat() const { return androidStream_->format; }\n-\tconst libcamera::PixelFormat &format() const { return format_; }\n-\tconst libcamera::Size &size() const { return size_; }\n \tType type() const { return type_; }\n \n \tconst libcamera::StreamConfiguration &streamConfiguration() const;\n \tlibcamera::Stream *stream() const;\n+\tconst libcamera::PixelFormat &format() const;\n+\tconst libcamera::Size &size() const;\n \n \tint configure(const libcamera::StreamConfiguration &cfg);\n \tint process(libcamera::FrameBuffer *source,\n@@ -127,13 +125,8 @@ public:\n \n private:\n \tCameraDevice *cameraDevice_;\n-\tlibcamera::CameraConfiguration *config_;\n-\tcamera3_stream_t *androidStream_;\n \tType type_;\n-\n-\t/* Libcamera facing format and sizes. */\n-\tlibcamera::PixelFormat format_;\n-\tlibcamera::Size size_;\n+\tcamera3_stream_t *androidStream_;\n \n \t/*\n \t * The index of the libcamera StreamConfiguration as added during\n@@ -141,6 +134,7 @@ private:\n \t * one or more streams to the Android framework.\n \t */\n \tunsigned int index_;\n+\tlibcamera::CameraConfiguration *config_;\n \tstd::unique_ptr<Encoder> encoder_;\n };\n \n","prefixes":["libcamera-devel","07/15"]}