From patchwork Tue Jan 22 23:45:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 338 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 61DFF60C7D for ; Wed, 23 Jan 2019 00:46:42 +0100 (CET) X-Halon-ID: e9e8992c-1e9f-11e9-911a-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id e9e8992c-1e9f-11e9-911a-0050569116f7; Wed, 23 Jan 2019 00:46:19 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 23 Jan 2019 00:45:01 +0100 Message-Id: <20190122234505.32634-5-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190122234505.32634-1-niklas.soderlund@ragnatech.se> References: <20190122234505.32634-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/8] libcamera: pipelines: add method to retrieve streams X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jan 2019 23:46:42 -0000 A Camera object needs to be able to inquire its responsible PipelineHandler for which streams it supports. Add and implement such an interface to the PipelineHandler base class and all pipeline handler implementations. Signed-off-by: Niklas Söderlund --- src/libcamera/include/pipeline_handler.h | 3 +++ src/libcamera/pipeline/ipu3/ipu3.cpp | 27 ++++++++++++++++++++++++ src/libcamera/pipeline/uvcvideo.cpp | 13 ++++++++++++ src/libcamera/pipeline/vimc.cpp | 13 ++++++++++++ src/libcamera/pipeline_handler.cpp | 12 +++++++++++ 5 files changed, 68 insertions(+) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index f05f201f7ca824eb..d4473bf173b815af 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -17,12 +17,15 @@ namespace libcamera { class CameraManager; class DeviceEnumerator; +class Stream; class PipelineHandler { public: virtual ~PipelineHandler() { }; + virtual std::vector streams(const Camera *camera) const = 0; + virtual bool match(CameraManager *manager, DeviceEnumerator *enumerator) = 0; }; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index c6106c538f071058..f73479125ed5e21d 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -10,6 +10,7 @@ #include #include +#include #include "device_enumerator.h" #include "log.h" @@ -26,6 +27,8 @@ public: PipelineHandlerIPU3(); ~PipelineHandlerIPU3(); + std::vector streams(const Camera *camera) const; + bool match(CameraManager *manager, DeviceEnumerator *enumerator); private: @@ -35,6 +38,8 @@ private: std::vector> cameras_; void registerCameras(CameraManager *manager); + + bool handleCamera(const Camera *camera) const; }; PipelineHandlerIPU3::PipelineHandlerIPU3() @@ -59,6 +64,16 @@ PipelineHandlerIPU3::~PipelineHandlerIPU3() imgu_ = nullptr; } +std::vector PipelineHandlerIPU3::streams(const Camera *camera) const +{ + std::vector streams; + + if (handleCamera(camera)) + streams.push_back(Stream(0)); + + return streams; +} + bool PipelineHandlerIPU3::match(CameraManager *manager, DeviceEnumerator *enumerator) { DeviceMatch cio2_dm("ipu3-cio2"); @@ -192,6 +207,18 @@ void PipelineHandlerIPU3::registerCameras(CameraManager *manager) } } +bool PipelineHandlerIPU3::handleCamera(const Camera *camera) const +{ + if (!camera) + return false; + + for (const std::shared_ptr &cam : cameras_) + if (camera == cam.get()) + return true; + + return false; +} + REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3); } /* namespace libcamera */ diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 3e4745ba498e7160..87b556ba0ae17696 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -7,6 +7,7 @@ #include #include +#include #include "device_enumerator.h" #include "log.h" @@ -23,6 +24,8 @@ public: PipelineHandlerUVC(); ~PipelineHandlerUVC(); + std::vector streams(const Camera *camera) const; + bool match(CameraManager *manager, DeviceEnumerator *enumerator); private: @@ -46,6 +49,16 @@ PipelineHandlerUVC::~PipelineHandlerUVC() dev_->release(); } +std::vector PipelineHandlerUVC::streams(const Camera *camera) const +{ + std::vector streams; + + if (camera && camera == camera_.get()) + streams.push_back(Stream(0)); + + return streams; +} + bool PipelineHandlerUVC::match(CameraManager *manager, DeviceEnumerator *enumerator) { DeviceMatch dm("uvcvideo"); diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index e8dbc0932ab0198a..e894367ba6706aaf 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -7,6 +7,7 @@ #include #include +#include #include "device_enumerator.h" #include "log.h" @@ -23,6 +24,8 @@ public: PipeHandlerVimc(); ~PipeHandlerVimc(); + std::vector streams(const Camera *camera) const; + bool match(CameraManager *manager, DeviceEnumerator *enumerator); private: @@ -46,6 +49,16 @@ PipeHandlerVimc::~PipeHandlerVimc() dev_->release(); } +std::vector PipeHandlerVimc::streams(const Camera *camera) const +{ + std::vector streams; + + if (camera && camera == camera_.get()) + streams.push_back(Stream(0)); + + return streams; +} + bool PipeHandlerVimc::match(CameraManager *manager, DeviceEnumerator *enumerator) { DeviceMatch dm("vimc"); diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index c24feeafc503e9b1..c2bed924dece0ac0 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -34,6 +34,18 @@ LOG_DEFINE_CATEGORY(Pipeline) * with the pipelines it supports and creates corresponding Camera devices. */ +/** + * \fn PipelineHandler::streams(const Camera *camera) + * \brief Retrive a array of all streams the camera provides + * \param[in] camera The camera to retrieve streams from + * + * This function is the interface to extract information about streams from a + * PipelineHandler. + * + * \return A array of streams from the camera or a empty list if \a camera + * is not part of the PipelineHandler. + */ + /** * \fn PipelineHandler::match(DeviceEnumerator *enumerator) * \brief Match media devices and create camera instances