From patchwork Mon Oct 5 10:46:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 9956 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 82ECDC3B5F for ; Mon, 5 Oct 2020 10:47:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4E6F363C30; Mon, 5 Oct 2020 12:47:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="gWuUuXcm"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 24E2863B82 for ; Mon, 5 Oct 2020 12:47:37 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AA6D259E; Mon, 5 Oct 2020 12:47:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1601894856; bh=gWnFdfQ82p8qI2GH2SoAhdCVCPTo1HR0A/KgjeK/8uo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gWuUuXcmqmSGxc48KWcraaymvTR/fjtBgCN3Jz5n0ZTT8NN8ebyoWDbdMwhzv6lGo 7+7kg1wzwDFEwWx/KUSk6bL/riSluLqvqzv2zhEhNa/mKusmcqZxVyxaEnP7NFx8e8 9U6xvdtbNg8ALaEdQgLpXqJBs6J5rWv5nDIGE82Q= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Oct 2020 13:46:43 +0300 Message-Id: <20201005104649.10812-10-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 09/15] android: camera_stream: Add FrameBufferAllocator X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Jacopo Mondi Add a FrameBufferAllocator class member to the CameraStream class. The allocator is constructed for CameraStream instances that needs internal allocation and deleted at class destruction time. The definition of a destructor for the class deletes the implicitly defined copy constructor, required as the CameraDevice stores CameraStream instances in a pre-reserved vector. In order to make the CameraStream copy-constructable it is required to make the encoder_ pointer decay to a raw pointer, as unique_ptr<> are not copy-constructable. Signed-off-by: Jacopo Mondi --- src/android/camera_stream.cpp | 13 +++++++++++-- src/android/camera_stream.h | 6 +++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 6e7419ae31b8..9f3e7026b1a4 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -19,12 +19,21 @@ LOG_DECLARE_CATEGORY(HAL); CameraStream::CameraStream(CameraDevice *cameraDev, Type type, camera3_stream_t *androidStream, unsigned int index) : cameraDevice_(cameraDev), type_(type), androidStream_(androidStream), - index_(index), encoder_(nullptr) + index_(index), encoder_(nullptr), allocator_(nullptr) { config_ = cameraDevice_->cameraConfiguration(); if (type_ == Type::Internal || type_ == Type::Mapped) - encoder_.reset(new EncoderLibJpeg); + encoder_ = new EncoderLibJpeg(); + + if (type == Type::Internal) + allocator_ = new FrameBufferAllocator(cameraDevice_->camera()); +} + +CameraStream::~CameraStream() +{ + delete encoder_; + delete allocator_; } const StreamConfiguration &CameraStream::streamConfiguration() const diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index b67b4c0ca0b3..eaf4357ed096 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -109,6 +110,8 @@ public: }; CameraStream(CameraDevice *cameraDev, Type type, camera3_stream_t *androidStream, unsigned int index); + CameraStream(const CameraStream &) = default; + ~CameraStream(); int outputFormat() const { return androidStream_->format; } Type type() const { return type_; } @@ -135,7 +138,8 @@ private: */ unsigned int index_; libcamera::CameraConfiguration *config_; - std::unique_ptr encoder_; + Encoder *encoder_; + libcamera::FrameBufferAllocator *allocator_; }; #endif /* __ANDROID_CAMERA_STREAM__ */