summaryrefslogtreecommitdiff
path: root/src/qcam/main_window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qcam/main_window.cpp')
-rw-r--r--src/qcam/main_window.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 5a2ac699..74427592 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -280,28 +280,24 @@ void MainWindow::toggleCapture(bool start)
*/
int MainWindow::startCapture()
{
+ StreamRoles roles = StreamKeyValueParser::roles(options_[OptStream]);
int ret;
- /* Configure the camera. */
- config_ = camera_->generateConfiguration({ StreamRole::Viewfinder });
-
- StreamConfiguration &cfg = config_->at(0);
-
- if (options_.isSet(OptSize)) {
- const std::vector<OptionValue> &sizeOptions =
- options_[OptSize].toArray();
+ /* Verify roles are supported. */
+ if (roles.size() != 1) {
+ qCritical() << "Only one stream supported";
+ return -EINVAL;
+ }
- /* Set desired stream size if requested. */
- for (const auto &value : sizeOptions) {
- KeyValueParser::Options opt = value.toKeyValues();
+ if (roles[0] != StreamRole::Viewfinder) {
+ qCritical() << "Only viewfinder supported";
+ return -EINVAL;
+ }
- if (opt.isSet("width"))
- cfg.size.width = opt["width"];
+ /* Configure the camera. */
+ config_ = camera_->generateConfiguration(roles);
- if (opt.isSet("height"))
- cfg.size.height = opt["height"];
- }
- }
+ StreamConfiguration &cfg = config_->at(0);
/* Use a format supported by the viewfinder if available. */
std::vector<PixelFormat> formats = cfg.formats().pixelformats();
@@ -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";