mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-18 18:05:09 +03:00
cam: Add --monitor option
Add --monitor to monitor new hotplug and unplug camera events from the CameraManager. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
785d741861
commit
70b65c6590
2 changed files with 29 additions and 0 deletions
|
@ -36,6 +36,8 @@ public:
|
||||||
void quit();
|
void quit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void cameraAdded(std::shared_ptr<Camera> cam);
|
||||||
|
void cameraRemoved(std::shared_ptr<Camera> cam);
|
||||||
int parseOptions(int argc, char *argv[]);
|
int parseOptions(int argc, char *argv[]);
|
||||||
int prepareConfig();
|
int prepareConfig();
|
||||||
int listControls();
|
int listControls();
|
||||||
|
@ -123,6 +125,12 @@ int CamApp::init(int argc, char **argv)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options_.isSet(OptMonitor)) {
|
||||||
|
cm_->cameraAdded.connect(this, &CamApp::cameraAdded);
|
||||||
|
cm_->cameraRemoved.connect(this, &CamApp::cameraRemoved);
|
||||||
|
std::cout << "Monitoring new hotplug and unplug events" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
loop_ = new EventLoop(cm_->eventDispatcher());
|
loop_ = new EventLoop(cm_->eventDispatcher());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -186,6 +194,9 @@ int CamApp::parseOptions(int argc, char *argv[])
|
||||||
"list-controls");
|
"list-controls");
|
||||||
parser.addOption(OptListProperties, OptionNone, "List cameras properties",
|
parser.addOption(OptListProperties, OptionNone, "List cameras properties",
|
||||||
"list-properties");
|
"list-properties");
|
||||||
|
parser.addOption(OptMonitor, OptionNone,
|
||||||
|
"Monitor for hotplug and unplug camera events",
|
||||||
|
"monitor");
|
||||||
parser.addOption(OptStrictFormats, OptionNone,
|
parser.addOption(OptStrictFormats, OptionNone,
|
||||||
"Do not allow requested stream format(s) to be adjusted",
|
"Do not allow requested stream format(s) to be adjusted",
|
||||||
"strict-formats");
|
"strict-formats");
|
||||||
|
@ -309,6 +320,16 @@ int CamApp::infoConfiguration()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CamApp::cameraAdded(std::shared_ptr<Camera> cam)
|
||||||
|
{
|
||||||
|
std::cout << "Camera Added: " << cam->name() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CamApp::cameraRemoved(std::shared_ptr<Camera> cam)
|
||||||
|
{
|
||||||
|
std::cout << "Camera Removed: " << cam->name() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
int CamApp::run()
|
int CamApp::run()
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -346,6 +367,13 @@ int CamApp::run()
|
||||||
return capture.run(options_);
|
return capture.run(options_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options_.isSet(OptMonitor)) {
|
||||||
|
std::cout << "Press Ctrl-C to interrupt" << std::endl;
|
||||||
|
ret = loop_->exec();
|
||||||
|
if (ret)
|
||||||
|
std::cout << "Failed to run monitor loop" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ enum {
|
||||||
OptInfo = 'I',
|
OptInfo = 'I',
|
||||||
OptList = 'l',
|
OptList = 'l',
|
||||||
OptListProperties = 'p',
|
OptListProperties = 'p',
|
||||||
|
OptMonitor = 'm',
|
||||||
OptStream = 's',
|
OptStream = 's',
|
||||||
OptListControls = 256,
|
OptListControls = 256,
|
||||||
OptStrictFormats = 257,
|
OptStrictFormats = 257,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue