summaryrefslogtreecommitdiffhomepage
path: root/video
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-05-02 18:46:36 +0200
committerStanislaw Halik <sthalik@misaki.pl>2019-05-02 18:55:46 +0200
commitbac58c2d5e45d838e32bc1d5cc0b12a19365c569 (patch)
tree500ee959c9b3925f2230ef362218bff82a29e798 /video
parent79ae08ed646f6cb2d242274ed04a79d669090143 (diff)
video: fallback to first available camera
Diffstat (limited to 'video')
-rw-r--r--video/camera.cpp17
-rw-r--r--video/camera.hpp4
2 files changed, 17 insertions, 4 deletions
diff --git a/video/camera.cpp b/video/camera.cpp
index c33ab13a..b5cf3120 100644
--- a/video/camera.cpp
+++ b/video/camera.cpp
@@ -37,14 +37,27 @@ bool show_dialog(const QString& camera_name)
return false;
}
-std::unique_ptr<camera_impl> make_camera(const QString& name)
+std::unique_ptr<camera_impl> make_camera_(const QString& name)
{
QMutexLocker l(&mtx);
for (auto& camera : metadata)
for (const QString& name_ : camera->camera_names())
if (name_ == name)
- return camera->make_camera(name);
+ return camera->make_camera(name_);
+
+ return nullptr;
+}
+
+std::unique_ptr<camera_impl> make_camera(const QString& name)
+{
+ if (auto ret = make_camera_(name))
+ return ret;
+
+ for (auto& camera : metadata)
+ for (const QString& name_ : camera->camera_names())
+ if (auto ret = camera->make_camera(name_); ret)
+ return ret;
return nullptr;
}
diff --git a/video/camera.hpp b/video/camera.hpp
index 9ff2821b..250bad36 100644
--- a/video/camera.hpp
+++ b/video/camera.hpp
@@ -85,8 +85,8 @@ namespace video
{
using camera_impl = impl::camera;
-OTR_VIDEO_EXPORT
-std::unique_ptr<camera_impl> make_camera(const QString& name);
+OTR_VIDEO_EXPORT std::unique_ptr<camera_impl> make_camera(const QString& name);
+OTR_VIDEO_EXPORT std::unique_ptr<camera_impl> make_camera_(const QString& name);
OTR_VIDEO_EXPORT
std::vector<QString> camera_names();