diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-06 07:49:15 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-22 17:13:59 +0300 |
commit | 7dab1fa58fb77ace2742dadf860d91f29474225f (patch) | |
tree | 990ff9173ccccea430f4f8f11667675ee481225c /src/cam/camera_session.cpp | |
parent | 5082fe7b5b9ea7e073e409fd8b73126951803456 (diff) |
cam: Make camera-related options sub-options of OptCamera
Use the new hierarchical options feature of the option parser to turn
camera-related option (--capture, --file, --stream, --strict-formats and
--metadata) into children of the --camera option. As an added bonus, we
don't need to check anymore if a camera has been specified when capture
is requested, as that's now enforced by the option parser.
This change prepares for support of multiple cameras.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/cam/camera_session.cpp')
-rw-r--r-- | src/cam/camera_session.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp index ceb2c3ab..f2383567 100644 --- a/src/cam/camera_session.cpp +++ b/src/cam/camera_session.cpp @@ -21,11 +21,11 @@ using namespace libcamera; CameraSession::CameraSession(CameraManager *cm, + const std::string &cameraId, const OptionsParser::Options &options) - : last_(0), queueCount_(0), captureCount_(0), + : options_(options), last_(0), queueCount_(0), captureCount_(0), captureLimit_(0), printMetadata_(false) { - const std::string &cameraId = options[OptCamera]; char *endptr; unsigned long index = strtoul(cameraId.c_str(), &endptr, 10); if (*endptr == '\0' && index > 0 && index <= cm->cameras().size()) @@ -44,7 +44,7 @@ CameraSession::CameraSession(CameraManager *cm, return; } - StreamRoles roles = StreamKeyValueParser::roles(options[OptStream]); + StreamRoles roles = StreamKeyValueParser::roles(options_[OptStream]); std::unique_ptr<CameraConfiguration> config = camera_->generateConfiguration(roles); @@ -56,12 +56,12 @@ CameraSession::CameraSession(CameraManager *cm, /* Apply configuration if explicitly requested. */ if (StreamKeyValueParser::updateConfiguration(config.get(), - options[OptStream])) { + options_[OptStream])) { std::cerr << "Failed to update configuration" << std::endl; return; } - bool strictFormats = options.isSet(OptStrictFormats); + bool strictFormats = options_.isSet(OptStrictFormats); switch (config->validate()) { case CameraConfiguration::Valid: @@ -134,14 +134,14 @@ void CameraSession::infoConfiguration() const } } -int CameraSession::start(const OptionsParser::Options &options) +int CameraSession::start() { int ret; queueCount_ = 0; captureCount_ = 0; - captureLimit_ = options[OptCapture].toInteger(); - printMetadata_ = options.isSet(OptMetadata); + captureLimit_ = options_[OptCapture].toInteger(); + printMetadata_ = options_.isSet(OptMetadata); ret = camera_->configure(config_.get()); if (ret < 0) { @@ -157,9 +157,9 @@ int CameraSession::start(const OptionsParser::Options &options) camera_->requestCompleted.connect(this, &CameraSession::requestComplete); - if (options.isSet(OptFile)) { - if (!options[OptFile].toString().empty()) - writer_ = std::make_unique<BufferWriter>(options[OptFile]); + if (options_.isSet(OptFile)) { + if (!options_[OptFile].toString().empty()) + writer_ = std::make_unique<BufferWriter>(options_[OptFile]); else writer_ = std::make_unique<BufferWriter>(); } |