cam: Store camera session pointer in CamApp class
Move the local CameraSession variable from the CamApp::run() function to a member variable of the CamApp class, created in CamApp::init(). This is a first step towards moving code to the CameraSession class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
24ca846a27
commit
34d986d1ec
2 changed files with 12 additions and 9 deletions
|
@ -34,11 +34,6 @@ int CameraSession::start(const OptionsParser::Options &options)
|
||||||
captureLimit_ = options[OptCapture].toInteger();
|
captureLimit_ = options[OptCapture].toInteger();
|
||||||
printMetadata_ = options.isSet(OptMetadata);
|
printMetadata_ = options.isSet(OptMetadata);
|
||||||
|
|
||||||
if (!camera_) {
|
|
||||||
std::cout << "Can't capture without a camera" << std::endl;
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = camera_->configure(config_);
|
ret = camera_->configure(config_);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
std::cout << "Failed to configure camera" << std::endl;
|
std::cout << "Failed to configure camera" << std::endl;
|
||||||
|
|
|
@ -51,8 +51,11 @@ private:
|
||||||
static CamApp *app_;
|
static CamApp *app_;
|
||||||
OptionsParser::Options options_;
|
OptionsParser::Options options_;
|
||||||
CameraManager *cm_;
|
CameraManager *cm_;
|
||||||
|
|
||||||
std::shared_ptr<Camera> camera_;
|
std::shared_ptr<Camera> camera_;
|
||||||
std::unique_ptr<libcamera::CameraConfiguration> config_;
|
std::unique_ptr<libcamera::CameraConfiguration> config_;
|
||||||
|
std::unique_ptr<CameraSession> session_;
|
||||||
|
|
||||||
EventLoop loop_;
|
EventLoop loop_;
|
||||||
|
|
||||||
bool strictFormats_;
|
bool strictFormats_;
|
||||||
|
@ -127,6 +130,9 @@ int CamApp::init(int argc, char **argv)
|
||||||
cleanup();
|
cleanup();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session_ = std::make_unique<CameraSession>(camera_, config_.get());
|
||||||
|
session_->captureDone.connect(this, &CamApp::captureDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptMonitor)) {
|
if (options_.isSet(OptMonitor)) {
|
||||||
|
@ -369,10 +375,12 @@ int CamApp::run()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options_.isSet(OptCapture)) {
|
if (options_.isSet(OptCapture)) {
|
||||||
CameraSession session(camera_, config_.get());
|
if (!camera_) {
|
||||||
session.captureDone.connect(this, &CamApp::captureDone);
|
std::cout << "Can't capture without a camera" << std::endl;
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
ret = session.start(options_);
|
ret = session_->start(options_);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
std::cout << "Failed to start camera session" << std::endl;
|
std::cout << "Failed to start camera session" << std::endl;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -380,7 +388,7 @@ int CamApp::run()
|
||||||
|
|
||||||
loop_.exec();
|
loop_.exec();
|
||||||
|
|
||||||
session.stop();
|
session_->stop();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue