cam: Use script parser to set controls
Add a "--script" option to the cam test application to allow specify a capture script to be used to drive the capture session. Add to the CameraSession class a script parser instance, created conditionally to the OptCaptureScript option. If the script parser has been created, use it at queueRequest time to retrieve the list of controls that has to be associated with a Request, and populate Request::controls() with it before queueing it to the Camera. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
3a91e37bb8
commit
568865a6c1
4 changed files with 22 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <libcamera/property_ids.h>
|
||||
|
||||
#include "camera_session.h"
|
||||
#include "capture_script.h"
|
||||
#include "event_loop.h"
|
||||
#include "file_sink.h"
|
||||
#ifdef HAVE_KMS
|
||||
|
@ -91,6 +92,16 @@ CameraSession::CameraSession(CameraManager *cm,
|
|||
}
|
||||
#endif
|
||||
|
||||
if (options_.isSet(OptCaptureScript)) {
|
||||
std::string scriptName = options_[OptCaptureScript].toString();
|
||||
script_ = std::make_unique<CaptureScript>(camera_, scriptName);
|
||||
if (!script_->valid()) {
|
||||
std::cerr << "Invalid capture script '" << scriptName
|
||||
<< "'" << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (config->validate()) {
|
||||
case CameraConfiguration::Valid:
|
||||
break;
|
||||
|
@ -322,6 +333,9 @@ int CameraSession::queueRequest(Request *request)
|
|||
if (captureLimit_ && queueCount_ >= captureLimit_)
|
||||
return 0;
|
||||
|
||||
if (script_)
|
||||
request->controls() = script_->frameControls(queueCount_);
|
||||
|
||||
queueCount_++;
|
||||
|
||||
return camera_->queueRequest(request);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue