mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-19 18:35:07 +03:00
qcam: Make use of StreamKeyValueParser
Use the StreamKeyValueParser helper to parse stream configuration from the command line. This extends qcam to accept role hints and pixel format in addition to a size. Currently only one viewfinder stream is supported, add a check to keep this behavior. Going forward this restriction will be lifted to support more then one stream. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
18cfea19dc
commit
d29c321357
4 changed files with 28 additions and 27 deletions
|
@ -280,29 +280,25 @@ void MainWindow::toggleCapture(bool start)
|
|||
*/
|
||||
int MainWindow::startCapture()
|
||||
{
|
||||
StreamRoles roles = StreamKeyValueParser::roles(options_[OptStream]);
|
||||
int ret;
|
||||
|
||||
/* Verify roles are supported. */
|
||||
if (roles.size() != 1) {
|
||||
qCritical() << "Only one stream supported";
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (roles[0] != StreamRole::Viewfinder) {
|
||||
qCritical() << "Only viewfinder supported";
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Configure the camera. */
|
||||
config_ = camera_->generateConfiguration({ StreamRole::Viewfinder });
|
||||
config_ = camera_->generateConfiguration(roles);
|
||||
|
||||
StreamConfiguration &cfg = config_->at(0);
|
||||
|
||||
if (options_.isSet(OptSize)) {
|
||||
const std::vector<OptionValue> &sizeOptions =
|
||||
options_[OptSize].toArray();
|
||||
|
||||
/* Set desired stream size if requested. */
|
||||
for (const auto &value : sizeOptions) {
|
||||
KeyValueParser::Options opt = value.toKeyValues();
|
||||
|
||||
if (opt.isSet("width"))
|
||||
cfg.size.width = opt["width"];
|
||||
|
||||
if (opt.isSet("height"))
|
||||
cfg.size.height = opt["height"];
|
||||
}
|
||||
}
|
||||
|
||||
/* Use a format supported by the viewfinder if available. */
|
||||
std::vector<PixelFormat> formats = cfg.formats().pixelformats();
|
||||
for (const PixelFormat &format : viewfinder_->nativeFormats()) {
|
||||
|
@ -316,6 +312,13 @@ int MainWindow::startCapture()
|
|||
}
|
||||
}
|
||||
|
||||
/* Allow user to override configuration. */
|
||||
if (StreamKeyValueParser::updateConfiguration(config_.get(),
|
||||
options_[OptStream])) {
|
||||
qWarning() << "Failed to update configuration";
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
CameraConfiguration::Status validation = config_->validate();
|
||||
if (validation == CameraConfiguration::Invalid) {
|
||||
qWarning() << "Failed to create valid camera configuration";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue