From patchwork Fri Jun 12 07:11:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5byg5pyd6Ziz?= X-Patchwork-Id: 26875 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 C8000C324C for ; Fri, 12 Jun 2026 07:11:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 694BD623BC; Fri, 12 Jun 2026 09:11:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=163.com header.i=@163.com header.b="kyDyxvRf"; dkim-atps=neutral Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.3]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DB2D861E76 for ; Fri, 12 Jun 2026 09:11:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=gO u8sBwxdi4A+C2evL4Hv6XZ06wwVQUQ95ciA4eYRNU=; b=kyDyxvRfPDCk3/nwzx LZsJSaDJuuMyMNsDrkCJc3m8/Y3TNq79NtHJ0LDWPJhOi1l/Z9zM6dBCMkTWScJX WDB1wHtMFnOyEajsG7Djt5F2H4Mf7k8puFbkQ5mr03fSlEpbLiNkH9lyCrsRzUbf qW9BNGcle6xq+vEKDKGBizb4E= Received: from SH-DESKTOP.taile2d4ba.ts.net (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wAXdCU0sStqndINCw--.56982S2; Fri, 12 Jun 2026 15:11:49 +0800 (CST) From: tju_cooyun@163.com To: libcamera-devel@lists.libcamera.org Cc: zcy Subject: [PATCH] libcamera: camera: make Camera::create private Date: Fri, 12 Jun 2026 15:11:17 +0800 Message-ID: <20260612071117.109431-1-tju_cooyun@163.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CM-TRANSID: _____wAXdCU0sStqndINCw--.56982S2 X-Coremail-Antispam: 1Uf129KBjvAXoWfGrWfCFWkXFW8GF15XFWkZwb_yoW8Jr4DCo Z5trW8Gw15Aryj9F1ftF1xKr1UA390k3s7Jw42ga1qya1fXrWYg3yxCF17ur1fGFWUGFn7 Ary2qF1xAF4j9FW8n29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjfUnfOwUUUUU X-Originating-IP: [183.195.143.58] X-CM-SenderInfo: 5wmxsuprr130i6rwjhhfrp/xtbC5hXeNmorsTWTrQAA3g 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: zcy Make Camera::create a private implementation detail since it is only used by pipeline handler subclasses. This prevents app users from misunderstanding or misusing the function. Add a protected PipelineHandler::createCamera helper so pipeline implementations can create Camera instances internally. --- Documentation/guides/pipeline-handler.rst | 13 +++++++------ include/libcamera/camera.h | 8 ++++---- include/libcamera/internal/pipeline_handler.h | 5 +++++ src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 2 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 2 +- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 3 +-- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 +- src/libcamera/pipeline/rpi/pisp/pisp.cpp | 2 +- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 2 +- src/libcamera/pipeline/simple/simple.cpp | 2 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 2 +- src/libcamera/pipeline/vimc/vimc.cpp | 2 +- src/libcamera/pipeline/virtual/virtual.cpp | 2 +- src/libcamera/pipeline_handler.cpp | 7 +++++++ 14 files changed, 33 insertions(+), 21 deletions(-) diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst index 083cdb745..2a661cf24 100644 --- a/Documentation/guides/pipeline-handler.rst +++ b/Documentation/guides/pipeline-handler.rst @@ -489,10 +489,11 @@ handler. Once the camera data has been initialized, the Camera device instances and the associated streams have to be registered. Create a set of streams for the -camera, which for this device is only one. You create a camera using the static -:doxy-int:`Camera::create` function, passing the Camera::Private instance, the -id of the camera, and the streams available. Then register the camera with the -pipeline handler and camera manager using :doxy-int:`PipelineHandler::registerCamera`. +camera, which for this device is only one. You create a camera using the +protected :doxy-int:`PipelineHandler::createCamera` helper, passing the +Camera::Private instance, the id of the camera, and the streams available. +Then register the camera with the pipeline handler and camera manager using +:doxy-int:`PipelineHandler::registerCamera`. Finally with a successful construction, we return 'true' indicating that the PipelineHandler successfully matched and constructed a device. @@ -501,7 +502,7 @@ PipelineHandler successfully matched and constructed a device. std::set streams{ &data->stream_ }; const char *id = data->video_->deviceName(); - std::shared_ptr camera = Camera::create(std::move(data), id, streams); + std::shared_ptr camera = createCamera(std::move(data), id, streams); registerCamera(std::move(camera)); return true; @@ -529,7 +530,7 @@ Our match function should now look like the following: /* Create and register the camera. */ std::set streams{ &data->stream_ }; const char *id = data->video_->deviceName(); - std::shared_ptr camera = Camera::create(std::move(data), id, streams); + std::shared_ptr camera = createCamera(std::move(data), id, streams); registerCamera(std::move(camera)); return true; diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index b24a29740..a5e8ba03a 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -116,10 +116,6 @@ class Camera final : public Object, public std::enable_shared_from_this, LIBCAMERA_DECLARE_PRIVATE() public: - static std::shared_ptr create(std::unique_ptr d, - const std::string &id, - const std::set &streams); - const std::string &id() const; Signal bufferCompleted; @@ -154,6 +150,10 @@ public: private: LIBCAMERA_DISABLE_COPY(Camera) + static std::shared_ptr create(std::unique_ptr d, + const std::string &id, + const std::set &streams); + Camera(std::unique_ptr d, const std::string &id, const std::set &streams); ~Camera(); diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 6922ce18e..69531b836 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -14,6 +14,7 @@ #include +#include #include #include @@ -80,6 +81,10 @@ public: } protected: + std::shared_ptr createCamera(std::unique_ptr d, + const std::string &id, + const std::set &streams); + void registerCamera(std::shared_ptr camera); void hotplugMediaDevice(std::shared_ptr media); unsigned int useCount() const { return useCount_; } diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index 706681fce..36a42eb8e 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -1101,7 +1101,7 @@ bool PipelineHandlerISI::match(DeviceEnumerator *enumerator) } std::shared_ptr camera = - Camera::create(std::move(data), id, streams); + createCamera(std::move(data), id, streams); registerCamera(std::move(camera)); numCameras++; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index bf4c2921f..7d36c148b 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1133,7 +1133,7 @@ int PipelineHandlerIPU3::registerCameras() /* Create and register the Camera instance. */ const std::string &cameraId = cio2->sensor()->id(); std::shared_ptr camera = - Camera::create(std::move(data), cameraId, streams); + createCamera(std::move(data), cameraId, streams); registerCamera(std::move(camera)); diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index ce2469ed1..62f7fafe1 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -1778,8 +1778,7 @@ bool PipelineHandlerMaliC55::registerMaliCamera(std::unique_ptrdsStream_); - std::shared_ptr camera = Camera::create(std::move(data), - name, streams); + std::shared_ptr camera = createCamera(std::move(data), name, streams); registerCamera(std::move(camera)); return true; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 9606459fc..48505c6b4 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1504,7 +1504,7 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) }; const std::string &id = data->sensor_->id(); std::shared_ptr camera = - Camera::create(std::move(data), id, streams); + createCamera(std::move(data), id, streams); registerCamera(std::move(camera)); diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index b744c901f..62bd4ad1d 100644 --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp @@ -1175,7 +1175,7 @@ int PipelineHandlerPiSP::platformRegister(std::unique_ptr &came /* Create and register the camera. */ const std::string &id = data->sensor_->id(); std::shared_ptr camera = - Camera::create(std::move(cameraData), id, streams); + createCamera(std::move(cameraData), id, streams); PipelineHandler::registerCamera(std::move(camera)); LOG(RPI, Info) << "Registered camera " << id diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index 3e9a49058..bf520b3a0 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -400,7 +400,7 @@ int PipelineHandlerVc4::platformRegister(std::unique_ptr &camer /* Create and register the camera. */ const std::string &id = data->sensor_->id(); std::shared_ptr camera = - Camera::create(std::move(cameraData), id, streams); + createCamera(std::move(cameraData), id, streams); PipelineHandler::registerCamera(std::move(camera)); LOG(RPI, Info) << "Registered camera " << id diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index c6fe12d65..4e672067c 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -2002,7 +2002,7 @@ bool SimplePipelineHandler::matchDevice(std::shared_ptr media, const std::string &id = data->sensor_->id(); std::shared_ptr camera = - Camera::create(std::move(data), id, streams); + createCamera(std::move(data), id, streams); registerCamera(std::move(camera)); registered = true; } diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 3bd51733d..88b0f23a1 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -485,7 +485,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) std::string id = data->id(); std::set streams{ &data->stream_ }; std::shared_ptr camera = - Camera::create(std::move(data), id, streams); + createCamera(std::move(data), id, streams); registerCamera(std::move(camera)); /* Enable hot-unplug notifications. */ diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 6681c74ee..b5518e6e8 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -510,7 +510,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) std::set streams{ &data->stream_ }; const std::string &id = data->sensor_->id(); std::shared_ptr camera = - Camera::create(std::move(data), id, streams); + createCamera(std::move(data), id, streams); registerCamera(std::move(camera)); return true; diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp index 81d2dddab..1ecfe9d13 100644 --- a/src/libcamera/pipeline/virtual/virtual.cpp +++ b/src/libcamera/pipeline/virtual/virtual.cpp @@ -402,7 +402,7 @@ bool PipelineHandlerVirtual::match([[maybe_unused]] DeviceEnumerator *enumerator for (auto &streamConfig : data->streamConfigs_) streams.insert(&streamConfig.stream); std::string id = data->config_.id; - std::shared_ptr camera = Camera::create(std::move(data), id, streams); + std::shared_ptr camera = createCamera(std::move(data), id, streams); if (!initFrameGenerator(camera.get())) { LOG(Virtual, Error) << "Failed to initialize frame " diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index e7145c1d4..c5cdbfda1 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -76,6 +76,13 @@ PipelineHandler::PipelineHandler(CameraManager *manager, { } +std::shared_ptr PipelineHandler::createCamera(std::unique_ptr d, + const std::string &id, + const std::set &streams) +{ + return Camera::create(std::move(d), id, streams); +} + PipelineHandler::~PipelineHandler() { for (std::shared_ptr &media : mediaDevices_)