diff --git a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraImplementations.cpp b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraImplementations.cpp index b9aa7eea8..05744f4fe 100644 --- a/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraImplementations.cpp +++ b/SerialPrograms/Source/CommonFramework/VideoPipeline/Backends/CameraImplementations.cpp @@ -5,6 +5,7 @@ */ #include +#include "Common/Cpp/PrettyPrint.h" #include "CommonFramework/GlobalSettingsPanel.h" #include "CameraImplementations.h" @@ -109,9 +110,12 @@ VideoBackendOption::VideoBackendOption() std::vector get_all_cameras(){ size_t index = GlobalSettings::instance().VIDEO_BACKEND.current_value(); const CameraBackend& backend = *CameraBackends::instance().m_backends[index].backend; -// cout << "Querying camera list..." << endl; + global_logger_tagged().log("Start loading camera list..."); + WallClock start = current_time(); std::vector ret = backend.get_all_cameras(); -// cout << "Done querying camera list..." << endl; + WallClock end = current_time(); + double seconds = std::chrono::duration_cast(end - start).count() / 1000.; + global_logger_tagged().log("Done loading camera list... " + tostr_fixed(seconds, 3) + " seconds"); return ret; } std::string get_camera_name(const CameraInfo& info){ diff --git a/SerialPrograms/Source/CommonFramework/VideoPipeline/UI/CameraSelectorWidget.cpp b/SerialPrograms/Source/CommonFramework/VideoPipeline/UI/CameraSelectorWidget.cpp index 86a179fb1..ade50c836 100644 --- a/SerialPrograms/Source/CommonFramework/VideoPipeline/UI/CameraSelectorWidget.cpp +++ b/SerialPrograms/Source/CommonFramework/VideoPipeline/UI/CameraSelectorWidget.cpp @@ -29,7 +29,8 @@ CameraSelectorWidget::~CameraSelectorWidget(){ CameraSelectorWidget::CameraSelectorWidget( CameraSession& session, Logger& logger, - VideoDisplayWidget& holder + VideoDisplayWidget& holder, + std::vector starting_camera_list ) : m_logger(logger) , m_session(session) @@ -45,7 +46,6 @@ CameraSelectorWidget::CameraSelectorWidget( m_camera_box = new NoWheelComboBox(this); camera_row->addWidget(m_camera_box, 5); -// update_camera_list(); camera_row->addSpacing(5); m_resolution_box = new NoWheelComboBox(this); @@ -55,7 +55,7 @@ CameraSelectorWidget::CameraSelectorWidget( m_reset_button = new QPushButton("Reset Camera", this); camera_row->addWidget(m_reset_button, 1); - update_camera_list(); + update_camera_list(std::move(starting_camera_list)); update_resolution_list(); connect( @@ -94,10 +94,13 @@ CameraSelectorWidget::CameraSelectorWidget( m_session.add_listener(*this); } void CameraSelectorWidget::update_camera_list(){ + update_camera_list(get_all_cameras()); +} +void CameraSelectorWidget::update_camera_list(std::vector cameras){ m_camera_box->clear(); m_camera_box->addItem("(none)"); - m_cameras = get_all_cameras(); + m_cameras = std::move(cameras); CameraInfo info = m_session.current_device(); size_t index = 0; diff --git a/SerialPrograms/Source/CommonFramework/VideoPipeline/UI/CameraSelectorWidget.h b/SerialPrograms/Source/CommonFramework/VideoPipeline/UI/CameraSelectorWidget.h index 296b73a80..4188f5408 100644 --- a/SerialPrograms/Source/CommonFramework/VideoPipeline/UI/CameraSelectorWidget.h +++ b/SerialPrograms/Source/CommonFramework/VideoPipeline/UI/CameraSelectorWidget.h @@ -38,12 +38,14 @@ class CameraSelectorWidget : public QWidget, public CameraSession::Listener{ CameraSelectorWidget( CameraSession& session, Logger& logger, - VideoDisplayWidget& holder + VideoDisplayWidget& holder, + std::vector starting_camera_list ); ~CameraSelectorWidget(); private: void update_camera_list(); + void update_camera_list(std::vector cameras); void update_resolution_list(); virtual void shutdown() override; diff --git a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_MultiSwitchSystemWidget.cpp b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_MultiSwitchSystemWidget.cpp index 6df3f4d3e..294f58eb6 100644 --- a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_MultiSwitchSystemWidget.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_MultiSwitchSystemWidget.cpp @@ -7,6 +7,7 @@ #include #include #include "Common/Qt/NoWheelComboBox.h" +#include "CommonFramework/VideoPipeline/Backends/CameraImplementations.h" #include "NintendoSwitch_SwitchSystemWidget.h" #include "NintendoSwitch_MultiSwitchSystemWidget.h" @@ -116,10 +117,18 @@ void MultiSwitchSystemWidget::redraw_videos(size_t count){ vbox->setContentsMargins(0, 0, 0, 0); // m_option.resize(count); + std::vector cameras = get_all_cameras(); for (size_t c = 0; c < m_session.count(); c++){ // const auto& item = m_option.m_switches[c]; // m_switches.emplace_back(item->make_ui(*this, m_logger, m_program_id)); - m_switches.emplace_back(new SwitchSystemWidget(*m_videos, m_session[c], m_program_id)); + m_switches.emplace_back( + new SwitchSystemWidget( + *m_videos, + m_session[c], + m_program_id, + cameras + ) + ); } QHBoxLayout* vrow0 = new QHBoxLayout(); diff --git a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SingleSwitchProgramWidget.cpp b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SingleSwitchProgramWidget.cpp index ba21ef1d9..21fef2b31 100644 --- a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SingleSwitchProgramWidget.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SingleSwitchProgramWidget.cpp @@ -13,6 +13,7 @@ #include "CommonFramework/NewVersionCheck.h" #include "CommonFramework/Panels/PanelTools.h" #include "CommonFramework/Panels/UI/PanelElements.h" +#include "CommonFramework/VideoPipeline/Backends/CameraImplementations.h" #include "CommonFramework/Tools/StatsTracking.h" #include "NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramOption.h" #include "NintendoSwitch_SingleSwitchProgramWidget.h" @@ -68,7 +69,12 @@ SingleSwitchProgramWidget2::SingleSwitchProgramWidget2( QVBoxLayout* scroll_layout = new QVBoxLayout(scroll_inner); scroll_layout->setAlignment(Qt::AlignTop); - m_system = new SwitchSystemWidget(*this, m_session.system(), m_session.instance_id()); + m_system = new SwitchSystemWidget( + *this, + m_session.system(), + m_session.instance_id(), + get_all_cameras() + ); scroll_layout->addWidget(m_system); m_options = option.options().make_QtWidget(*this); diff --git a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.cpp b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.cpp index fab861557..1fd8e4008 100644 --- a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.cpp @@ -40,7 +40,8 @@ SwitchSystemWidget::~SwitchSystemWidget(){ SwitchSystemWidget::SwitchSystemWidget( QWidget& parent, SwitchSystemSession& session, - uint64_t program_id + uint64_t program_id, + std::vector starting_camera_list ) : QWidget(&parent) , m_session(session) @@ -77,7 +78,12 @@ SwitchSystemWidget::SwitchSystemWidget( ); video_holder->addWidget(m_video_display); - m_camera_widget = new CameraSelectorWidget(m_session.camera_session(), m_session.logger(), *m_video_display); + m_camera_widget = new CameraSelectorWidget( + m_session.camera_session(), + m_session.logger(), + *m_video_display, + std::move(starting_camera_list) + ); group_layout->addWidget(m_camera_widget); m_audio_widget = new AudioSelectorWidget(*widget, m_session.logger(), m_session.audio_session()); diff --git a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.h b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.h index e91f439e9..11699a7a0 100644 --- a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.h +++ b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.h @@ -40,7 +40,8 @@ class SwitchSystemWidget final : public QWidget, public CommandReceiver{ SwitchSystemWidget( QWidget& parent, SwitchSystemSession& session, - uint64_t program_id + uint64_t program_id, + std::vector starting_camera_list ); public: diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_VirtualConsole.cpp b/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_VirtualConsole.cpp index 136be0ff0..198c59487 100644 --- a/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_VirtualConsole.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_VirtualConsole.cpp @@ -8,6 +8,7 @@ #include #include "Common/Cpp/Json/JsonValue.h" #include "Common/Qt/CollapsibleGroupBox.h" +#include "CommonFramework/VideoPipeline/Backends/CameraImplementations.h" #include "NintendoSwitch/Framework/UI/NintendoSwitch_SwitchSystemWidget.h" #include "NintendoSwitch_VirtualConsole.h" @@ -76,7 +77,7 @@ void VirtualConsole_Widget::construct(){ QVBoxLayout* scroll_layout = new QVBoxLayout(scroll_inner); scroll_layout->setAlignment(Qt::AlignTop); - m_switch = new SwitchSystemWidget(*this, m_session, 0); + m_switch = new SwitchSystemWidget(*this, m_session, 0, get_all_cameras()); scroll_layout->addWidget(m_switch); }