From 9e7f180ccda89baad29f57d2f8f8118211f60eb8 Mon Sep 17 00:00:00 2001 From: Mysticial Date: Fri, 29 Sep 2023 02:40:20 -0700 Subject: [PATCH] Extend camera caching to Qt6. --- SerialPrograms/CMakeLists.txt | 4 ++-- .../VideoPipeline/Backends/CameraWidgetQt6.5.cpp | 2 +- .../VideoPipeline/Backends/CameraWidgetQt6.cpp | 11 ++++++++++- .../{MediaServicesQt6.5.cpp => MediaServicesQt6.cpp} | 4 ++-- .../{MediaServicesQt6.5.h => MediaServicesQt6.h} | 0 5 files changed, 15 insertions(+), 6 deletions(-) rename SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/{MediaServicesQt6.5.cpp => MediaServicesQt6.cpp} (92%) rename SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/{MediaServicesQt6.5.h => MediaServicesQt6.h} (100%) diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index d362ddd0f..d573afc42 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -540,8 +540,8 @@ file(GLOB MAIN_SOURCES Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.5.h Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.cpp Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.h - Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.5.cpp - Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.5.h + Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.cpp + Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.h Source/CommonFramework/VideoPipeline/Backends/VideoToolsQt5.cpp Source/CommonFramework/VideoPipeline/Backends/VideoToolsQt5.h Source/CommonFramework/VideoPipeline/CameraInfo.h diff --git a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.5.cpp b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.5.cpp index 4fb5087ff..830c786c3 100644 --- a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.5.cpp +++ b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.5.cpp @@ -19,7 +19,7 @@ //#include "Common/Cpp/Time.h" //#include "Common/Cpp/PrettyPrint.h" #include "CommonFramework/VideoPipeline/CameraOption.h" -#include "MediaServicesQt6.5.h" +#include "MediaServicesQt6.h" #include "CameraWidgetQt6.5.h" //using std::cout; diff --git a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.cpp b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.cpp index d02e4ef65..9a7466a48 100644 --- a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.cpp +++ b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraWidgetQt6.cpp @@ -16,6 +16,7 @@ //#include "Common/Cpp/Exceptions.h" //#include "Common/Cpp/Time.h" #include "CommonFramework/VideoPipeline/CameraOption.h" +#include "MediaServicesQt6.h" #include "CameraWidgetQt6.h" //using std::cout; @@ -27,15 +28,23 @@ namespace CameraQt6QVideoSink{ std::vector CameraBackend::get_all_cameras() const{ - std::vector ret; +#if 1 + const auto cameras = GlobalMediaServices::instance().get_all_cameras(); +#else const auto cameras = QMediaDevices::videoInputs(); +#endif + std::vector ret; for (const auto& info : cameras){ ret.emplace_back(info.id().toStdString()); } return ret; } std::string CameraBackend::get_camera_name(const CameraInfo& info) const{ +#if 1 + const auto cameras = GlobalMediaServices::instance().get_all_cameras(); +#else const auto cameras = QMediaDevices::videoInputs(); +#endif for (const auto& camera : cameras){ if (camera.id().toStdString() == info.device_name()){ return camera.description().toStdString(); diff --git a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.5.cpp b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.cpp similarity index 92% rename from SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.5.cpp rename to SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.cpp index 422487308..428c97694 100644 --- a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.5.cpp +++ b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.cpp @@ -5,12 +5,12 @@ */ #include -#if QT_VERSION_MAJOR == 6 && QT_VERSION_MINOR >= 5 +#if QT_VERSION_MAJOR == 6 #include "Common/Cpp/PrettyPrint.h" #include "Common/Cpp/Time.h" #include "CommonFramework/Logging/Logger.h" -#include "MediaServicesQt6.5.h" +#include "MediaServicesQt6.h" namespace PokemonAutomation{ diff --git a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.5.h b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.h similarity index 100% rename from SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.5.h rename to SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/MediaServicesQt6.h