summaryrefslogtreecommitdiff
path: root/src/cam/main.cpp
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-07-24 14:59:15 +0200
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-07-27 17:31:13 +0200
commit01ea694003094b51bd96883055b11e52a011bef9 (patch)
tree21ba33a6f21cb75ce3006472217a6f61c512377b /src/cam/main.cpp
parent3acc31b0e3bdb7a53d52ab32136aaf46f1af6ce7 (diff)
cam: Add option to disallow adjusting of requested formats
Add a '--strict-formats' option which fails the camera configuration step if the format is adjusted, Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/cam/main.cpp')
-rw-r--r--src/cam/main.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index 2512fe9d..ead0abe3 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -49,12 +49,15 @@ private:
std::shared_ptr<Camera> camera_;
std::unique_ptr<libcamera::CameraConfiguration> config_;
EventLoop *loop_;
+
+ bool strictFormats_;
};
CamApp *CamApp::app_ = nullptr;
CamApp::CamApp()
- : cm_(nullptr), camera_(nullptr), config_(nullptr), loop_(nullptr)
+ : cm_(nullptr), camera_(nullptr), config_(nullptr), loop_(nullptr),
+ strictFormats_(false)
{
CamApp::app_ = this;
}
@@ -77,6 +80,9 @@ int CamApp::init(int argc, char **argv)
if (ret < 0)
return ret;
+ if (options_.isSet(OptStrictFormats))
+ strictFormats_ = true;
+
cm_ = new CameraManager();
ret = cm_->start();
@@ -179,6 +185,9 @@ int CamApp::parseOptions(int argc, char *argv[])
"list-controls");
parser.addOption(OptListProperties, OptionNone, "List cameras properties",
"list-properties");
+ parser.addOption(OptStrictFormats, OptionNone,
+ "Do not allow requested stream format(s) to be adjusted",
+ "strict-formats");
options_ = parser.parse(argc, argv);
if (!options_.valid())
@@ -214,6 +223,12 @@ int CamApp::prepareConfig()
case CameraConfiguration::Valid:
break;
case CameraConfiguration::Adjusted:
+ if (strictFormats_) {
+ std::cout << "Adjusting camera configuration disallowed by --strict-formats argument"
+ << std::endl;
+ config_.reset();
+ return -EINVAL;
+ }
std::cout << "Camera configuration adjusted" << std::endl;
break;
case CameraConfiguration::Invalid: