diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/pipeline/meson.build | 1 | ||||
-rw-r--r-- | src/libcamera/pipeline/uvcvideo.cpp | 59 |
2 files changed, 60 insertions, 0 deletions
diff --git a/src/libcamera/pipeline/meson.build b/src/libcamera/pipeline/meson.build index 811c075b..40bb2640 100644 --- a/src/libcamera/pipeline/meson.build +++ b/src/libcamera/pipeline/meson.build @@ -1,4 +1,5 @@ libcamera_sources += files([ + 'uvcvideo.cpp', 'vimc.cpp', ]) diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp new file mode 100644 index 00000000..3ba69da8 --- /dev/null +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * uvcvideo.cpp - Pipeline handler for uvcvideo devices + */ + +#include <libcamera/camera.h> +#include <libcamera/camera_manager.h> + +#include "device_enumerator.h" +#include "media_device.h" +#include "pipeline_handler.h" + +namespace libcamera { + +class PipelineHandlerUVC : public PipelineHandler +{ +public: + PipelineHandlerUVC(); + ~PipelineHandlerUVC(); + + bool match(CameraManager *manager, DeviceEnumerator *enumerator); + +private: + MediaDevice *dev_; +}; + +PipelineHandlerUVC::PipelineHandlerUVC() + : dev_(nullptr) +{ +} + +PipelineHandlerUVC::~PipelineHandlerUVC() +{ + if (dev_) + dev_->release(); +} + +bool PipelineHandlerUVC::match(CameraManager *manager, DeviceEnumerator *enumerator) +{ + DeviceMatch dm("uvcvideo"); + + dev_ = enumerator->search(dm); + + if (!dev_) + return false; + + dev_->acquire(); + + std::shared_ptr<Camera> camera = Camera::create(dev_->model()); + manager->addCamera(std::move(camera)); + + return true; +} + +REGISTER_PIPELINE_HANDLER(PipelineHandlerUVC); + +} /* namespace libcamera */ |