summaryrefslogtreecommitdiff
path: root/src/cam
diff options
context:
space:
mode:
Diffstat (limited to 'src/cam')
-rw-r--r--src/cam/camera_session.cpp5
-rw-r--r--src/cam/main.cpp16
2 files changed, 12 insertions, 9 deletions
diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp
index 1fb7c1b6..7bb75e86 100644
--- a/src/cam/camera_session.cpp
+++ b/src/cam/camera_session.cpp
@@ -34,11 +34,6 @@ int CameraSession::start(const OptionsParser::Options &options)
captureLimit_ = options[OptCapture].toInteger();
printMetadata_ = options.isSet(OptMetadata);
- if (!camera_) {
- std::cout << "Can't capture without a camera" << std::endl;
- return -ENODEV;
- }
-
ret = camera_->configure(config_);
if (ret < 0) {
std::cout << "Failed to configure camera" << std::endl;
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index b13230c3..2c6500a5 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -51,8 +51,11 @@ private:
static CamApp *app_;
OptionsParser::Options options_;
CameraManager *cm_;
+
std::shared_ptr<Camera> camera_;
std::unique_ptr<libcamera::CameraConfiguration> config_;
+ std::unique_ptr<CameraSession> session_;
+
EventLoop loop_;
bool strictFormats_;
@@ -127,6 +130,9 @@ int CamApp::init(int argc, char **argv)
cleanup();
return ret;
}
+
+ session_ = std::make_unique<CameraSession>(camera_, config_.get());
+ session_->captureDone.connect(this, &CamApp::captureDone);
}
if (options_.isSet(OptMonitor)) {
@@ -369,10 +375,12 @@ int CamApp::run()
}
if (options_.isSet(OptCapture)) {
- CameraSession session(camera_, config_.get());
- session.captureDone.connect(this, &CamApp::captureDone);
+ if (!camera_) {
+ std::cout << "Can't capture without a camera" << std::endl;
+ return -ENODEV;
+ }
- ret = session.start(options_);
+ ret = session_->start(options_);
if (ret) {
std::cout << "Failed to start camera session" << std::endl;
return ret;
@@ -380,7 +388,7 @@ int CamApp::run()
loop_.exec();
- session.stop();
+ session_->stop();
return 0;
}