mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-14 16:09:51 +03:00
libcamera: Add ControlValidator implementation for Camera
Add a new CameraControlValidator class that implements the ControlValidator interface for a Camera object. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
aae2b5d666
commit
f671d84ceb
4 changed files with 85 additions and 0 deletions
53
src/libcamera/camera_controls.cpp
Normal file
53
src/libcamera/camera_controls.cpp
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2019, Google Inc.
|
||||||
|
*
|
||||||
|
* camera_controls.cpp - Camera controls
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "camera_controls.h"
|
||||||
|
|
||||||
|
#include <libcamera/camera.h>
|
||||||
|
#include <libcamera/controls.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file camera_controls.h
|
||||||
|
* \brief Controls for Camera instances
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace libcamera {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class CameraControlValidator
|
||||||
|
* \brief A control validator for Camera instances
|
||||||
|
*
|
||||||
|
* This ControlValidator specialisation validates that controls exist in the
|
||||||
|
* Camera associated with the validator.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Construst a CameraControlValidator for the \a camera
|
||||||
|
* \param[in] camera The camera
|
||||||
|
*/
|
||||||
|
CameraControlValidator::CameraControlValidator(Camera *camera)
|
||||||
|
: camera_(camera)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &CameraControlValidator::name() const
|
||||||
|
{
|
||||||
|
return camera_->name();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Validate a control
|
||||||
|
* \param[in] id The control ID
|
||||||
|
* \return True if the control is valid, false otherwise
|
||||||
|
*/
|
||||||
|
bool CameraControlValidator::validate(const ControlId &id) const
|
||||||
|
{
|
||||||
|
const ControlInfoMap &controls = camera_->controls();
|
||||||
|
return controls.find(&id) != controls.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace libcamera */
|
30
src/libcamera/include/camera_controls.h
Normal file
30
src/libcamera/include/camera_controls.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2019, Google Inc.
|
||||||
|
*
|
||||||
|
* camera_controls.h - Camera controls
|
||||||
|
*/
|
||||||
|
#ifndef __LIBCAMERA_CAMERA_CONTROLS_H__
|
||||||
|
#define __LIBCAMERA_CAMERA_CONTROLS_H__
|
||||||
|
|
||||||
|
#include "control_validator.h"
|
||||||
|
|
||||||
|
namespace libcamera {
|
||||||
|
|
||||||
|
class Camera;
|
||||||
|
|
||||||
|
class CameraControlValidator final : public ControlValidator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CameraControlValidator(Camera *camera);
|
||||||
|
|
||||||
|
const std::string &name() const override;
|
||||||
|
bool validate(const ControlId &id) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Camera *camera_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace libcamera */
|
||||||
|
|
||||||
|
#endif /* __LIBCAMERA_CAMERA_CONTROLS_H__ */
|
|
@ -1,4 +1,5 @@
|
||||||
libcamera_headers = files([
|
libcamera_headers = files([
|
||||||
|
'camera_controls.h',
|
||||||
'camera_sensor.h',
|
'camera_sensor.h',
|
||||||
'control_validator.h',
|
'control_validator.h',
|
||||||
'device_enumerator.h',
|
'device_enumerator.h',
|
||||||
|
|
|
@ -2,6 +2,7 @@ libcamera_sources = files([
|
||||||
'bound_method.cpp',
|
'bound_method.cpp',
|
||||||
'buffer.cpp',
|
'buffer.cpp',
|
||||||
'camera.cpp',
|
'camera.cpp',
|
||||||
|
'camera_controls.cpp',
|
||||||
'camera_manager.cpp',
|
'camera_manager.cpp',
|
||||||
'camera_sensor.cpp',
|
'camera_sensor.cpp',
|
||||||
'controls.cpp',
|
'controls.cpp',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue