diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp index 97c1ae449..f63fcb228 100644 --- a/src/apps/cam/camera_session.cpp +++ b/src/apps/cam/camera_session.cpp @@ -62,11 +62,32 @@ CameraSession::CameraSession(CameraManager *cm, return; } - std::vector roles = StreamKeyValueParser::roles(options_[OptStream]); + std::vector roles = + StreamKeyValueParser::roles(options_[OptStream]); + std::vector> tryRoles; + if (!roles.empty()) { + /* + * If the roles are explicitly specified then there's no need + * to try other roles + */ + tryRoles.push_back(roles); + } else { + tryRoles.push_back({ StreamRole::Viewfinder }); + tryRoles.push_back({ StreamRole::Raw }); + } - std::unique_ptr config = - camera_->generateConfiguration(roles); - if (!config || config->size() != roles.size()) { + std::unique_ptr config; + bool valid = false; + for (std::vector &rolesIt : tryRoles) { + config = camera_->generateConfiguration(rolesIt); + if (config && config->size() == rolesIt.size()) { + roles = rolesIt; + valid = true; + break; + } + } + + if (!valid) { std::cerr << "Failed to get default stream configuration" << std::endl; return; diff --git a/src/apps/common/stream_options.cpp b/src/apps/common/stream_options.cpp index 99239e07e..288f86530 100644 --- a/src/apps/common/stream_options.cpp +++ b/src/apps/common/stream_options.cpp @@ -42,9 +42,8 @@ KeyValueParser::Options StreamKeyValueParser::parse(const char *arguments) std::vector StreamKeyValueParser::roles(const OptionValue &values) { - /* If no configuration values to examine default to viewfinder. */ if (values.empty()) - return { StreamRole::Viewfinder }; + return {}; const std::vector &streamParameters = values.toArray(); diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp index d2ccbd231..224a7e5a6 100644 --- a/src/apps/qcam/main_window.cpp +++ b/src/apps/qcam/main_window.cpp @@ -356,6 +356,9 @@ int MainWindow::startCapture() /* Verify roles are supported. */ switch (roles.size()) { + case 0: + roles[0] = StreamRole::Viewfinder; + break; case 1: if (roles[0] != StreamRole::Viewfinder) { qWarning() << "Only viewfinder supported for single stream";